erasure: Commit data before xl.meta in RenameData() (#10734)

This will reduce the chance to have updated xl.meta without data.
This commit is contained in:
Anis Elleuch 2020-10-24 05:54:58 +01:00 committed by GitHub
parent 2c32c2149e
commit 00124c56d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2224,10 +2224,7 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath, dataDir,
return err
}
if err = renameAll(srcFilePath, dstFilePath); err != nil {
return osErrToFileErr(err)
}
// Commit data
if srcDataPath != "" {
removeAll(oldDstDataPath)
removeAll(dstDataPath)
@ -2236,6 +2233,11 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath, dataDir,
}
}
// Commit meta-file
if err = renameAll(srcFilePath, dstFilePath); err != nil {
return osErrToFileErr(err)
}
// Remove parent dir of the source file if empty
if parentDir := slashpath.Dir(srcFilePath); isDirEmpty(parentDir) {
deleteFile(srcVolumeDir, parentDir, false)