mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user