Skip to content

Commit b53b23a

Browse files
mag1c-hMag1c.H
authored andcommitted
fix: only delete activated dir when it differs from archived dir
1 parent f7c3569 commit b53b23a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ucm/store/nfsstore/cc/domain/space/space_manager.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,20 @@ Status SpaceManager::CommitBlock(const std::string& blockId, bool success) const
9595
{
9696
const auto activatedParent = this->layout_->DataFileParent(blockId, true);
9797
const auto activatedFile = this->layout_->DataFilePath(blockId, true);
98+
const auto archivedParent = this->layout_->DataFileParent(blockId, false);
9899
auto status = Status::OK();
99100
do {
100101
if (!success) { break; }
101-
const auto archivedParent = this->layout_->DataFileParent(blockId, false);
102-
const auto archivedFile = this->layout_->DataFilePath(blockId, false);
103102
if (archivedParent != activatedParent) {
104103
status = File::MkDir(archivedParent);
105104
if (status == Status::DuplicateKey()) { status = Status::OK(); }
106105
if (status.Failure()) { break; }
107106
}
107+
const auto archivedFile = this->layout_->DataFilePath(blockId, false);
108108
status = File::Rename(activatedFile, archivedFile);
109109
} while (0);
110110
File::Remove(activatedFile);
111-
File::RmDir(activatedParent);
111+
if (!success || archivedParent != activatedParent) { File::RmDir(activatedParent); }
112112
if (status.Failure()) {
113113
UC_ERROR("Failed({}) to {} block({}).", status, success ? "commit" : "cancel", blockId);
114114
}

0 commit comments

Comments
 (0)