Skip to content

Commit

Permalink
fix: improve symlink handling in cut operation
Browse files Browse the repository at this point in the history
Modify symlink handling in DoCutFilesWorker to defer deletion until after
successful link creation:

- Replace immediate deletion with deferred deletion via cutAndDeleteFiles list
- Only add symlink to deletion list if creation was successful
- Maintain existing completion tracking behavior

This change prevents premature deletion of symlinks and ensures atomic
cut operations for symbolic links.

Log: improve symlink handling during cut operations
Bug: https://pms.uniontech.com/bug-view-278451.html
  • Loading branch information
liyigang1 committed Nov 13, 2024
1 parent 4978779 commit 0401ad3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ bool DoCutFilesWorker::checkSymLink(const DFileInfoPointer &fileInfo)
bool ok = createSystemLink(fileInfo, newTargetInfo, true, false, &skip);
if (!ok && !skip)
return false;
ok = deleteFile(sourceUrl, QUrl(), &skip);
if (!ok && !skip)
return false;

if (ok && !skip)
cutAndDeleteFiles.append(fileInfo);

completeSourceFiles.append(sourceUrl);
completeTargetFiles.append(newTargetInfo->uri());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ bool FileOperateBaseWorker::copyAndDeleteFile(const DFileInfoPointer &fromInfo,
ok = createSystemLink(fromInfo, toInfo, workData->jobFlags.testFlag(AbstractJobHandler::JobFlag::kCopyFollowSymlink), true, skip);
if (ok) {
workData->zeroOrlinkOrDirWriteSize += FileUtils::getMemoryPageSize();
cutAndDeleteFiles.append(fromInfo);
if (!skip || !*skip)
cutAndDeleteFiles.append(fromInfo);
}
} else if (fromInfo->attribute(DFileInfo::AttributeID::kStandardIsDir).toBool()) {
ok = checkAndCopyDir(fromInfo, toInfo, skip);
Expand Down

0 comments on commit 0401ad3

Please sign in to comment.