Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unable to open multiple files with invalid links #2043

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/dfm-base/file/local/localfilehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,14 @@ bool LocalFileHandler::openFiles(const QList<QUrl> &fileUrls)

QList<QUrl> pathList;
bool result = false;

d->invalidPath.clear();
for (QUrl &fileUrl : urls) {
FileInfoPointer fileInfo = InfoFactory::create<FileInfo>(fileUrl);
QUrl sourceUrl = fileUrl;
QStringList targetList;
targetList.append(fileUrl.path());
FileInfoPointer fileInfoLink = fileInfo;

while (fileInfoLink->isAttributes(OptInfoType::kIsSymLink)) {
QString targetLink = fileInfoLink->pathOf(PathInfoType::kSymLinkTarget);
targetLink = targetLink.endsWith(QDir::separator()) && targetLink != QDir::separator() ? QString(targetLink).left(targetLink.length() - 1)
Expand All @@ -304,6 +306,7 @@ bool LocalFileHandler::openFiles(const QList<QUrl> &fileUrls)
d->lastEvent = DialogManagerInstance->showBreakSymlinkDialog(fileInfoLink->nameOf(
NameInfoType::kFileName),
fileInfo->urlOf(UrlInfoType::kUrl));
d->invalidPath << sourceUrl;
return d->lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kUnknowType;
}
}
Expand Down Expand Up @@ -1206,6 +1209,11 @@ DFMIOErrorCode LocalFileHandler::errorCode()
return d->lastError.code();
}

QList<QUrl> LocalFileHandler::getInvalidPath()
{
return d->invalidPath;
}

GlobalEventType LocalFileHandler::lastEventType()
{
return d->lastEvent;
Expand Down
2 changes: 1 addition & 1 deletion src/dfm-base/file/local/localfilehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class LocalFileHandler
bool deleteFile(const QUrl &url);
bool deleteFileRecursive(const QUrl &url);
bool setFileTime(const QUrl &url, const QDateTime &accessDateTime, const QDateTime &lastModifiedTime);

bool renameFilesBatch(const QMap<QUrl, QUrl> &urls, QMap<QUrl, QUrl> &successUrls);
bool doHiddenFileRemind(const QString &name, bool *checkRule = nullptr);

QString defaultTerminalPath();
GlobalEventType lastEventType();
QString errorString();
DFMIOErrorCode errorCode();
QList<QUrl> getInvalidPath();

private:
QScopedPointer<LocalFileHandlerPrivate> d;
Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/file/local/localfilehandler_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class LocalFileHandlerPrivate
LocalFileHandler *q { nullptr };
DFMIOError lastError;
GlobalEventType lastEvent = GlobalEventType::kUnknowType;
QList<QUrl> invalidPath; //BUG:https://pms.uniontech.com/bug-view-259909.html,记录无效链接路径
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,15 +869,16 @@ bool FileOperationsEventReceiver::handleOperationOpenFiles(const quint64 windowI
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);
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kDeleteFiles, windowId, fileHandler.getInvalidPath(), AbstractJobHandler::JobFlag::kNoHint, nullptr);
else if (lastEvent == DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash)
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash, windowId, urls, AbstractJobHandler::JobFlag::kNoHint, nullptr);
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kMoveToTrash, windowId, fileHandler.getInvalidPath(), AbstractJobHandler::JobFlag::kNoHint, nullptr);
} else {
// deal open file with custom dialog
dpfSlotChannel->push("dfmplugin_utils", "slot_OpenWith_ShowDialog", windowId, urls);
dpfSlotChannel->push("dfmplugin_utils", "slot_OpenWith_ShowDialog", windowId, fileHandler.getInvalidPath());
ok = true;
}
}

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