tests: Add tests for snapshot compatibility and recovery between versions
This commit is contained in:
@ -17,6 +17,7 @@ package fileutil
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -165,3 +166,16 @@ func RemoveMatchFile(lg *zap.Logger, dir string, matchFunc func(fileName string)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListFiles lists files if matchFunc is true on an existing dir
|
||||
// Returns error if the dir does not exist
|
||||
func ListFiles(dir string, matchFunc func(fileName string) bool) ([]string, error) {
|
||||
var files []string
|
||||
err := filepath.Walk(dir, func(path string, info fs.FileInfo, err error) error {
|
||||
if matchFunc(path) {
|
||||
files = append(files, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return files, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user