[Pkg-owncloud-commits] [owncloud-client] 71/94: Don't delete contents behind directory junctions #6322
Sandro Knauß
hefee at debian.org
Thu Mar 29 11:12:16 UTC 2018
This is an automated email from the git hooks/post-receive script.
hefee pushed a commit to branch upstream
in repository owncloud-client.
commit 22b19636e901637a0b8eded4bc36480b25823157
Author: Christian Kamm <mail at ckamm.de>
Date: Wed Feb 7 10:45:58 2018 +0100
Don't delete contents behind directory junctions #6322
QFileInfo::isSymLink() does detect reparse points that are symlinks but
returns false for junctions. The new function FileSystem::isJunction()
can detect those and is used to not recursively delete files inside
directories that are junctions.
See also https://bugreports.qt.io/browse/QTBUG-45344 and the
discussion in the PR https://codereview.qt-project.org/#/c/113019/.
---
src/common/filesystembase.cpp | 18 ++++++++++++++++++
src/common/filesystembase.h | 8 ++++++++
src/libsync/propagatorjobs.cpp | 2 +-
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp
index 1d95e39..1a1ac45 100644
--- a/src/common/filesystembase.cpp
+++ b/src/common/filesystembase.cpp
@@ -478,4 +478,22 @@ bool FileSystem::isLnkFile(const QString &filename)
return filename.endsWith(".lnk");
}
+bool FileSystem::isJunction(const QString &filename)
+{
+#ifdef Q_OS_WIN
+ WIN32_FIND_DATA findData;
+ HANDLE hFind = FindFirstFileEx((const wchar_t *)filename.utf16(), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ FindClose(hFind);
+ return false;
+ }
+ return findData.dwFileAttributes != INVALID_FILE_ATTRIBUTES
+ && findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT
+ && findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT;
+#else
+ Q_UNUSED(filename);
+ return false;
+#endif
+}
+
} // namespace OCC
diff --git a/src/common/filesystembase.h b/src/common/filesystembase.h
index 9568dac..39f073a 100644
--- a/src/common/filesystembase.h
+++ b/src/common/filesystembase.h
@@ -141,8 +141,16 @@ namespace FileSystem {
*/
bool OCSYNC_EXPORT isFileLocked(const QString &fileName);
+ /**
+ * Returns whether the file is a shortcut file (ends with .lnk)
+ */
bool OCSYNC_EXPORT isLnkFile(const QString &filename);
+ /**
+ * Returns whether the file is a junction (windows only)
+ */
+ bool OCSYNC_EXPORT isJunction(const QString &filename);
+
/*
* This function takes a path and converts it to a UNC representation of the
* string. That means that it prepends a \\?\ (unless already UNC) and converts
diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp
index 49ecfe1..5e680ce 100644
--- a/src/libsync/propagatorjobs.cpp
+++ b/src/libsync/propagatorjobs.cpp
@@ -66,7 +66,7 @@ bool PropagateLocalRemove::removeRecursively(const QString &path)
bool ok;
// The use of isSymLink here is okay:
// we never want to go into this branch for .lnk files
- bool isDir = fi.isDir() && !fi.isSymLink();
+ bool isDir = fi.isDir() && !fi.isSymLink() && !FileSystem::isJunction(fi.absoluteFilePath());
if (isDir) {
ok = removeRecursively(path + QLatin1Char('/') + di.fileName()); // recursive
} else {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list