summaryrefslogtreecommitdiffstats
path: root/helpers/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/path.go')
-rw-r--r--helpers/path.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/helpers/path.go b/helpers/path.go
index b302b1569..73970d558 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -459,9 +459,17 @@ func IsDir(path string, fs afero.Fs) (bool, error) {
return afero.IsDir(fs, path)
}
-// IsEmpty checks if a given path is empty.
+// IsEmpty checks if a given path is empty, meaning it doesn't contain any regular files.
func IsEmpty(path string, fs afero.Fs) (bool, error) {
- return afero.IsEmpty(fs, path)
+ var hasFile bool
+ err := afero.Walk(fs, path, func(path string, info os.FileInfo, err error) error {
+ if info.IsDir() {
+ return nil
+ }
+ hasFile = true
+ return filepath.SkipDir
+ })
+ return !hasFile, err
}
// Exists checks if a file or directory exists.