fs: add more detailed logging for file includes/excludes

This makes a DEBUG log to show why files were included or excluded.

Fixes #7463
This commit is contained in:
Kyle Reynolds 2024-01-22 11:46:26 -05:00 committed by GitHub
parent 810644e873
commit 7835991147
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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)