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.
This commit is contained in:
Chris Lu
2026-05-09 14:44:47 -07:00
parent 1690bb2a03
commit 849d7949a3
+2 -2
View File
@@ -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) {