Skip to content

Commit af1db84

Browse files
committed
Don't cache old id if a copy is detected
1 parent 751f66a commit af1db84

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pkg/storage/fs/posix/tree/assimilation.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,16 +924,24 @@ func (t *Tree) WarmupIDCache(root string, assimilate, onlyDirty bool) error {
924924

925925
if id != "" {
926926
// Check if the item on the previous still exists. In this case it might have been a copy with extended attributes -> set new ID
927+
isCopy := false
927928
previousPath, ok := t.lookup.GetCachedID(context.Background(), spaceID, id)
928929
if ok && previousPath != path {
929-
// this id clashes with an existing id -> re-assimilate
930930
_, err := os.Stat(previousPath)
931931
if err == nil {
932-
_ = t.assimilate(scanItem{Path: path, Trigger: "warmup id cache - id clash"})
932+
// previous path still exists -> this is a copy
933+
isCopy = true
933934
}
934935
}
935-
if err := t.lookup.CacheID(context.Background(), spaceID, id, path); err != nil {
936-
t.log.Error().Err(err).Str("spaceID", spaceID).Str("id", id).Str("path", path).Msg("could not cache id")
936+
if isCopy {
937+
// copy detected -> re-assimilate
938+
_ = t.assimilate(scanItem{Path: path, Trigger: "warmup id cache - id clash, previous path: " + previousPath})
939+
} else {
940+
// update cache with new path
941+
t.log.Debug().Str("path", path).Str("id", id).Msg("caching id")
942+
if err := t.lookup.CacheID(context.Background(), spaceID, id, path); err != nil {
943+
t.log.Error().Err(err).Str("spaceID", spaceID).Str("id", id).Str("path", path).Msg("could not cache id")
944+
}
937945
}
938946
}
939947
} else if assimilate {

0 commit comments

Comments
 (0)