Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs: add more detailed logging for file includes/excludes

Kyle Reynolds783599114760
diff --git a/fs/filter/filter.go b/fs/filter/filter.go
index 736495f4d..ede0828ee 100644
--- a/fs/filter/filter.go
+++ b/fs/filter/filter.go
@@ -330,23 +330,30 @@ func (f *Filter) DirContainsExcludeFile(ctx context.Context, fremote fs.Fs, remo
}
// Include returns whether this object should be included into the
-// sync or not
+// sync or not and logs the reason for exclusion if not included
func (f *Filter) Include(remote string, size int64, modTime time.Time, metadata fs.Metadata) bool {
// filesFrom takes precedence
if f.files != nil {
_, include := f.files[remote]
+ if !include {
+ fs.Debugf(remote, "Excluded (FilesFrom Filter)")
+ }
return include
}
if !f.ModTimeFrom.IsZero() && modTime.Before(f.ModTimeFrom) {
+ fs.Debugf(remote, "Excluded (ModTime Filter)")
return false
}
if !f.ModTimeTo.IsZero() && modTime.After(f.ModTimeTo) {
+ fs.Debugf(remote, "Excluded (ModTime Filter)")
return false
}
if f.Opt.MinSize >= 0 && size < int64(f.Opt.MinSize) {
+ fs.Debugf(remote, "Excluded (Size Filter)")
return false
}
if f.Opt.MaxSize >= 0 && size > int64(f.Opt.MaxSize) {
+ fs.Debugf(remote, "Excluded (Size Filter)")
return false
}
if f.metaRules.len() > 0 {
@@ -360,10 +367,15 @@ func (f *Filter) Include(remote string, size int64, modTime time.Time, metadata
metadatas = append(metadatas, "\x00=\x00")
}
if !f.metaRules.includeMany(metadatas) {
+ fs.Debugf(remote, "Excluded (Metadata Filter)")
return false
}
}
- return f.IncludeRemote(remote)
+ include := f.IncludeRemote(remote)
+ if !include {
+ fs.Debugf(remote, "Excluded (Path Filter)")
+ }
+ return include
}
// IncludeObject returns whether this object should be included into
diff --git a/fs/walk/walk.go b/fs/walk/walk.go
index 01251ea1b..ada7a284d 100644
--- a/fs/walk/walk.go
+++ b/fs/walk/walk.go
@@ -320,8 +320,6 @@ func listR(ctx context.Context, f fs.Fs, path string, includeAll bool, listType
}
if include {
filteredEntries = append(filteredEntries, entry)
- } else {
- fs.Debugf(entry, "Excluded from sync (and deletion)")
}
}
entries = filteredEntries
@@ -480,8 +478,6 @@ func walkRDirTree(ctx context.Context, f fs.Fs, startPath string, includeAll boo
dirs.Add(x)
excluded = false
}
- } else {
- fs.Debugf(x, "Excluded from sync (and deletion)")
}
// Make sure we include any parent directories of excluded objects
if excluded {
@@ -511,7 +507,6 @@ func walkRDirTree(ctx context.Context, f fs.Fs, startPath string, includeAll boo
if basename == excludeFile {
excludeDir := parentDir(x.Remote())
toPrune[excludeDir] = true
- fs.Debugf(basename, "Excluded from sync (and deletion) based on exclude file")
}
}
}
@@ -529,8 +524,6 @@ func walkRDirTree(ctx context.Context, f fs.Fs, startPath string, includeAll boo
dirs.AddDir(x)
}
}
- } else {
- fs.Debugf(x, "Excluded from sync (and deletion)")
}
default:
return fmt.Errorf("unknown object type %T", entry)