filer.conf: match inode_index rules on path boundaries

A rule on /exports_old read as active for /exports because the check was a raw prefix match. Rule keys now have to equal the path or extend past a '/' boundary.
This commit is contained in:
Chris Lu committed 2026-10-22 02:27:05 -07:00
1 parent c551bea9ce
commit eeeda21a67
2 files changed
+7 -1

No files matched your search

+5 -1
View File
@@ -259,9 +259,13 @@ func (fc *FilerConf) InodeIndexActiveUnder(dirPath string) bool {
if fc.MatchStorageRule(dirPath).InodeIndex {
return true
}
prefix := dirPath
if !strings.HasSuffix(prefix, "/") {
prefix += "/"
}
active := false
fc.rules.Walk(func(key []byte, value *filer_pb.FilerConf_PathConf) bool {
if value.InodeIndex && strings.HasPrefix(string(key), dirPath) {
if value.InodeIndex && (string(key) == dirPath || strings.HasPrefix(string(key), prefix)) {
active = true
return false
}
+2
View File
@@ -296,6 +296,8 @@ func TestInodeIndexActiveUnder(t *testing.T) {
assert.True(t, fc.InodeIndexActiveUnder("/exports"))
assert.True(t, fc.InodeIndexActiveUnder("/exports/sub"))
assert.False(t, fc.InodeIndexActiveUnder("/other"))
assert.False(t, fc.InodeIndexActiveUnder("/exp"))
assert.False(t, fc.InodeIndexActiveUnder("/export"))
assert.False(t, NewFilerConf().InodeIndexActiveUnder("/"))
}