Skip to content

Commit

Permalink
fix: Unable to open multiple files with invalid links
Browse files Browse the repository at this point in the history
Clicking to confirm the deletion of invalid links will delete all files and prevent them from opening properly

Log: Open multiple files normally, open other files, delete only invalid links
Bug: https://pms.uniontech.com/bug-view-259909.html
  • Loading branch information
yang233000 committed Jun 24, 2024
1 parent 59e7bb3 commit cbf5fae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/dfm-base/file/local/localfilehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ bool LocalFileHandler::openFiles(const QList<QUrl> &fileUrls)

for (QUrl &fileUrl : urls) {
FileInfoPointer fileInfo = InfoFactory::create<FileInfo>(fileUrl);
QUrl SourceUrl = fileUrl;
QStringList targetList;
targetList.append(fileUrl.path());
FileInfoPointer fileInfoLink = fileInfo;
Expand All @@ -304,7 +305,8 @@ bool LocalFileHandler::openFiles(const QList<QUrl> &fileUrls)
d->lastEvent = DialogManagerInstance->showBreakSymlinkDialog(fileInfoLink->nameOf(
NameInfoType::kFileName),
fileInfo->urlOf(UrlInfoType::kUrl));
return d->lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kUnknowType;
isValidPath << SourceUrl;
continue;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/file/local/localfilehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class LocalFileHandler
GlobalEventType lastEventType();
QString errorString();
DFMIOErrorCode errorCode();
QList<QUrl> isValidPath;

private:
QScopedPointer<LocalFileHandlerPrivate> d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,19 +865,17 @@ bool FileOperationsEventReceiver::handleOperationOpenFiles(const quint64 windowI

DFMBASE_NAMESPACE::LocalFileHandler fileHandler;
bool ok = fileHandler.openFiles(urls);
if (!ok) {
DFMBASE_NAMESPACE::GlobalEventType lastEvent = fileHandler.lastEventType();
if (lastEvent != DFMBASE_NAMESPACE::GlobalEventType::kUnknowType) {
if (lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kDeleteFiles)
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kDeleteFiles, windowId, urls, AbstractJobHandler::JobFlag::kNoHint, nullptr);
else if (lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash)
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash, windowId, urls, AbstractJobHandler::JobFlag::kNoHint, nullptr);
} else {
// deal open file with custom dialog
dpfSlotChannel->push("dfmplugin_utils", "slot_OpenWith_ShowDialog", windowId, urls);
ok = true;
DFMBASE_NAMESPACE::GlobalEventType lastEvent = fileHandler.lastEventType();
if (lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kDeleteFiles)
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kDeleteFiles, windowId, fileHandler.isValidPath, AbstractJobHandler::JobFlag::kNoHint, nullptr);
else if (lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash)
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash, windowId, fileHandler.isValidPath, AbstractJobHandler::JobFlag::kNoHint, nullptr);
else if(!ok && lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kUnknowType){
// deal open file with custom dialog
dpfSlotChannel->push("dfmplugin_utils", "slot_OpenWith_ShowDialog", windowId, fileHandler.isValidPath);
ok = true;
}
}

dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kOpenFilesResult, windowId, urls, ok, error);
return ok;
}
Expand Down

0 comments on commit cbf5fae

Please sign in to comment.