summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2024-01-04 21:21:43 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2024-01-04 21:21:43 +0200
commit4e158f6bfa7d0747d8da70b3b15a44b52e35bb8a (patch)
tree84e20982138de5c9b6d319bf83ac79bd672f918f /src/corelib/io/qfilesystemengine_unix.cpp
parente4391422574aa9aa89fece74f16c07c609cbbae2 (diff)
parenta13fd415d689be046c13cc562cbbbb5df0e6506a (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.13' into tqtc/lts-5.15-opensourcev5.15.13-lts-lgpl
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 42739097f2..01aed7ad14 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -44,6 +44,7 @@
#include "qfile.h"
#include "qstorageinfo.h"
#include "qtextstream.h"
+#include "qurl.h"
#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/private/qcore_unix_p.h>
@@ -1392,6 +1393,16 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
const QString targetPath = trashDir.filePath(filesDir) + uniqueTrashedName;
const QFileSystemEntry target(targetPath);
+ QString infoPath;
+ const QStorageInfo storageInfo(sourcePath);
+ if (storageInfo.isValid() && storageInfo.rootPath() != rootPath() && storageInfo != QStorageInfo(QDir::home())) {
+ infoPath = sourcePath.mid(storageInfo.rootPath().length());
+ if (infoPath.front() == u'/')
+ infoPath = infoPath.mid(1);
+ } else {
+ infoPath = sourcePath;
+ }
+
/*
We might fail to rename if source and target are on different file systems.
In that case, we don't try further, i.e. copying and removing the original
@@ -1408,7 +1419,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
out.setCodec("UTF-8");
#endif
out << "[Trash Info]" << Qt::endl;
- out << "Path=" << sourcePath << Qt::endl;
+ out << "Path=" << QUrl::toPercentEncoding(infoPath, "/") << Qt::endl;
out << "DeletionDate="
<< QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-ddThh:mm:ss")) << Qt::endl;
infoFile.close();