From 849d7949a344a50a0af8e09ff1bd6c0e68f182ef Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 9 May 2026 14:44:47 -0700 Subject: [PATCH] fix(ec): normalize paths when matching ghost residue Use filepath.Clean on both the freshly opened output file names and the ghost paths so that lexically different but equivalent paths (e.g. "./datadir/X.ec00" vs "datadir/X.ec00") still match. Without this, a redundant entry in additionalDirs could let a ghost path slip through the overwritten check and os.Remove a freshly rebuilt shard. --- weed/storage/erasure_coding/ec_encoder.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/storage/erasure_coding/ec_encoder.go b/weed/storage/erasure_coding/ec_encoder.go index 51ea908b6..db927197a 100644 --- a/weed/storage/erasure_coding/ec_encoder.go +++ b/weed/storage/erasure_coding/ec_encoder.go @@ -226,11 +226,11 @@ func generateMissingEcFiles(baseFileName string, bufferSize int, largeBlockSize freshOutputs := make(map[string]struct{}, len(outputFiles)) for _, f := range outputFiles { if f != nil { - freshOutputs[f.Name()] = struct{}{} + freshOutputs[filepath.Clean(f.Name())] = struct{}{} } } for _, ghost := range ghostPaths { - if _, overwritten := freshOutputs[ghost]; overwritten { + if _, overwritten := freshOutputs[filepath.Clean(ghost)]; overwritten { continue } if removeErr := os.Remove(ghost); removeErr != nil && !os.IsNotExist(removeErr) {