From 9a62a86ad09c8ccf26ac1b21621789255535db21 Mon Sep 17 00:00:00 2001 From: liyigang Date: Wed, 19 Jun 2024 17:53:38 +0800 Subject: [PATCH] fix: When restoring files with long file names from trash, the prompt window icon and file size display error for replacing existing files Create a fileinfo using the scheme of trash, retrieve the restored original path, and recreate the fileinfo Log: When restoring files with long file names from trash, the prompt window icon and file size display error for replacing existing files Bug: https://pms.uniontech.com/bug-view-259587.html --- .../fileoperationutils/fileoperatebaseworker.cpp | 1 - .../fileoperations/trashfiles/dorestoretrashfilesworker.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp index 2bbf9cb3f6..3e592edf5d 100644 --- a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp +++ b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp @@ -786,7 +786,6 @@ void FileOperateBaseWorker::initCopyWay() QUrl FileOperateBaseWorker::trashInfo(const DFileInfoPointer &fromInfo) { - auto parentPath = parentUrl(fromInfo->uri()).path(); if (!parentPath.endsWith("files")) return QUrl(); diff --git a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/trashfiles/dorestoretrashfilesworker.cpp b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/trashfiles/dorestoretrashfilesworker.cpp index 1f5b4b7355..2918d5f4fb 100644 --- a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/trashfiles/dorestoretrashfilesworker.cpp +++ b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/trashfiles/dorestoretrashfilesworker.cpp @@ -173,8 +173,11 @@ bool DoRestoreTrashFilesWorker::doRestoreTrashFiles() } } DFileInfoPointer fileInfo { new DFileInfo(url) }; + // read trash info QUrl trashInfoUrl { fileInfo->attribute(DFileInfo::AttributeID::kStandardTargetUri).toString().replace("/files/", "/info/") + ".trashinfo" }; + QUrl trashUrl = QUrl(fileInfo->attribute(DFileInfo::AttributeID::kStandardTargetUri).toString()); + fileInfo.reset(new DFileInfo(trashUrl)); const QString &trashInfoCache { DFMIO::DFile(trashInfoUrl).readAll() }; emitCurrentTaskNotify(url, restoreInfo->uri()); bool ok = false;