Browse Source

go vet

pull/8292/head
Chris Lu 11 hours ago
parent
commit
3481ad22cb
  1. 4
      weed/filer/empty_folder_cleanup/empty_folder_cleaner.go
  2. 14
      weed/filer/empty_folder_cleanup/empty_folder_cleaner_test.go

4
weed/filer/empty_folder_cleanup/empty_folder_cleaner.go

@ -400,7 +400,7 @@ func autoRemoveEmptyFoldersEnabled(attrs map[string][]byte) (bool, string) {
return true, "<no_attrs>"
}
value, found := attrs[s3_constants.ExtAutoRemoveEmptyFolders]
value, found := attrs[s3_constants.ExtAllowEmptyFolders]
if !found {
return true, "<missing>"
}
@ -410,7 +410,7 @@ func autoRemoveEmptyFoldersEnabled(attrs map[string][]byte) (bool, string) {
return true, "<empty>"
}
return !strings.EqualFold(text, "false"), text
return !strings.EqualFold(text, "true"), text
}
// isUnderPath checks if child is under parent path

14
weed/filer/empty_folder_cleanup/empty_folder_cleaner_test.go

@ -160,20 +160,20 @@ func Test_autoRemoveEmptyFoldersEnabled(t *testing.T) {
attrValue: "<missing>",
},
{
name: "false disables cleanup",
name: "allow-empty disables cleanup",
attrs: map[string][]byte{
s3_constants.ExtAutoRemoveEmptyFolders: []byte("false"),
s3_constants.ExtAllowEmptyFolders: []byte("true"),
},
enabled: false,
attrValue: "false",
attrValue: "true",
},
{
name: "true enables cleanup",
name: "explicit false keeps cleanup enabled",
attrs: map[string][]byte{
s3_constants.ExtAutoRemoveEmptyFolders: []byte("true"),
s3_constants.ExtAllowEmptyFolders: []byte("false"),
},
enabled: true,
attrValue: "true",
attrValue: "false",
},
}
@ -750,7 +750,7 @@ func TestEmptyFolderCleaner_executeCleanup_bucketPolicyDisabledSkips(t *testing.
},
attrsFn: func(path util.FullPath) (map[string][]byte, error) {
if string(path) == "/buckets/test" {
return map[string][]byte{s3_constants.ExtAutoRemoveEmptyFolders: []byte("false")}, nil
return map[string][]byte{s3_constants.ExtAllowEmptyFolders: []byte("true")}, nil
}
return nil, nil
},

Loading…
Cancel
Save