diff --git a/fs/filter.go b/fs/filter.go index 25f4db27f..a8ea27b8d 100644 --- a/fs/filter.go +++ b/fs/filter.go @@ -28,8 +28,8 @@ var ( filesFrom = pflag.StringP("files-from", "", "", "Read list of source-file names from file") minAge = pflag.StringP("min-age", "", "", "Don't transfer any file younger than this in s or suffix ms|s|m|h|d|w|M|y") maxAge = pflag.StringP("max-age", "", "", "Don't transfer any file older than this in s or suffix ms|s|m|h|d|w|M|y") - minSize SizeSuffix - maxSize SizeSuffix + minSize = SizeSuffix(-1) + maxSize = SizeSuffix(-1) dumpFilters = pflag.BoolP("dump-filters", "", false, "Dump the filters to the output") //cvsExclude = pflag.BoolP("cvs-exclude", "C", false, "Exclude files in the same way CVS does") ) @@ -342,8 +342,8 @@ func (f *Filter) InActive() bool { return (f.files == nil && f.ModTimeFrom.IsZero() && f.ModTimeTo.IsZero() && - f.MinSize == 0 && - f.MaxSize == 0 && + f.MinSize < 0 && + f.MaxSize < 0 && f.fileRules.len() == 0 && f.dirRules.len() == 0) } @@ -390,10 +390,10 @@ func (f *Filter) Include(remote string, size int64, modTime time.Time) bool { if !f.ModTimeTo.IsZero() && modTime.After(f.ModTimeTo) { return false } - if f.MinSize != 0 && size < f.MinSize { + if f.MinSize >= 0 && size < f.MinSize { return false } - if f.MaxSize != 0 && size > f.MaxSize { + if f.MaxSize >= 0 && size > f.MaxSize { return false } return f.includeRemote(remote) diff --git a/fs/filter_test.go b/fs/filter_test.go index 9159e7fba..3838919f1 100644 --- a/fs/filter_test.go +++ b/fs/filter_test.go @@ -49,8 +49,8 @@ func TestNewFilterDefault(t *testing.T) { f, err := NewFilter() require.NoError(t, err) assert.False(t, f.DeleteExcluded) - assert.Equal(t, int64(0), f.MinSize) - assert.Equal(t, int64(0), f.MaxSize) + assert.Equal(t, int64(-1), f.MinSize) + assert.Equal(t, int64(-1), f.MaxSize) assert.Len(t, f.fileRules.rules, 0) assert.Len(t, f.dirRules.rules, 0) assert.Nil(t, f.files) @@ -109,8 +109,8 @@ func TestNewFilterFull(t *testing.T) { rm(*excludeFrom) rm(*includeFrom) rm(*filesFrom) - minSize = 0 - maxSize = 0 + minSize = -1 + maxSize = -1 deleteExcluded = &isFalse filterRule = &emptyString filterFrom = &emptyString @@ -352,7 +352,6 @@ func TestNewFilterMatches(t *testing.T) { {"a/one.png", 101, 0, false}, {"unicorn", 99, 0, false}, }) - t.Log(f.DumpFilters()) testDirInclude(t, f, []includeDirTest{ {"sausage1", false}, {"sausage2", false}, diff --git a/fs/operations_test.go b/fs/operations_test.go index 83e71306f..b4f850851 100644 --- a/fs/operations_test.go +++ b/fs/operations_test.go @@ -709,7 +709,7 @@ func TestSyncWithExclude(t *testing.T) { fs.Config.Filter.MaxSize = 40 defer func() { - fs.Config.Filter.MaxSize = 0 + fs.Config.Filter.MaxSize = -1 }() fs.Stats.ResetCounters() @@ -742,7 +742,7 @@ func TestSyncWithExcludeAndDeleteExcluded(t *testing.T) { fs.Config.Filter.MaxSize = 40 fs.Config.Filter.DeleteExcluded = true defer func() { - fs.Config.Filter.MaxSize = 0 + fs.Config.Filter.MaxSize = -1 fs.Config.Filter.DeleteExcluded = false }() @@ -999,7 +999,7 @@ func TestDelete(t *testing.T) { fs.Config.Filter.MaxSize = 60 defer func() { - fs.Config.Filter.MaxSize = 0 + fs.Config.Filter.MaxSize = -1 }() err := fs.Delete(r.fremote)