From eeeda21a674cb9b9ea0acbab9031b4086b67290c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 22 Oct 2026 02:27:05 -0700 Subject: [PATCH] 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. --- weed/filer/filer_conf.go | 6 +++++- weed/filer/filer_inode_index_test.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/weed/filer/filer_conf.go b/weed/filer/filer_conf.go index d61c68173b..ed53cbca98 100644 --- a/weed/filer/filer_conf.go +++ b/weed/filer/filer_conf.go @@ -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 } diff --git a/weed/filer/filer_inode_index_test.go b/weed/filer/filer_inode_index_test.go index 9172dd383a..034c1fd3ec 100644 --- a/weed/filer/filer_inode_index_test.go +++ b/weed/filer/filer_inode_index_test.go @@ -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("/")) }