mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 06:20:48 +02:00
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:
1 parent
c551bea9ce
commit
eeeda21a67
2 files changed
+7
-1
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
@@ -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("/"))
|
||||
}
|
||||
Reference in new issue
Block a user