Ignore *.lnk files on Windows.
authorallexzander <blackslayer4@gmail.com>
Thu, 1 Apr 2021 14:54:45 +0000 (17:54 +0300)
committerallexzander (Rebase PR Action) <allexzander@users.noreply.github.com>
Wed, 7 Apr 2021 09:08:02 +0000 (09:08 +0000)
Signed-off-by: allexzander <blackslayer4@gmail.com>
src/libsync/discovery.cpp
src/libsync/discoveryphase.cpp
src/libsync/vfs/cfapi/vfs_cfapi.cpp

index 9c3f2d9d003ac1cf55b61b629e21a68702a855a6..636e64c9de0fc395ce416108637a76501d2bd363 100644 (file)
@@ -180,9 +180,15 @@ void ProcessDirectoryJob::process()
         // local stat function.
         // Recall file shall not be ignored (#4420)
         bool isHidden = e.localEntry.isHidden || (f.first[0] == '.' && f.first != QLatin1String(".sys.admin#recall#"));
+#ifdef Q_OS_WIN
+        // exclude ".lnk" files as they are not essential, but, causing troubles when enabling the VFS due to QFileInfo::isDir() and other methods are freezing, which causes the ".lnk" files to start hydrating and freezing the app eventually.
+        const bool isServerEntrySymLink = !e.localEntry.isValid() && e.serverEntry.isValid() && !e.serverEntry.isDirectory && FileSystem::isLnkFile(e.serverEntry.name);
+#else
+        const bool isServerEntrySymLink = false;
+#endif
         if (handleExcluded(path._target, e.localEntry.name,
                 e.localEntry.isDirectory || e.serverEntry.isDirectory, isHidden,
-                e.localEntry.isSymLink))
+                e.localEntry.isSymLink || isServerEntrySymLink))
             continue;
 
         if (_queryServer == InBlackList || _discoveryData->isInSelectiveSyncBlackList(path._original)) {
@@ -509,14 +515,8 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(
         if (!localEntry.isValid()
             && item->_type == ItemTypeFile
             && opts._vfs->mode() != Vfs::Off
-            && _pinState != PinState::AlwaysLocal
-#ifdef Q_OS_WIN
-            // on Windows, ".lnk" files are causing troubles with QFileInfo - always treat them as normal files
-            && !FileSystem::isLnkFile(path._server)
-#endif
-            ) {
+            && _pinState != PinState::AlwaysLocal) {
             item->_type = ItemTypeVirtualFile;
-
             if (isVfsWithSuffix())
                 addVirtualFileSuffix(tmp_path._original);
         }
index c8b522dcfcea626838eecf7deef3f44121aebc59..5cb1c7c55be58a1fcbdef2e0168cf6483b91e111 100644 (file)
@@ -20,6 +20,9 @@
 
 #include "common/asserts.h"
 #include "common/checksums.h"
+#ifdef Q_OS_WIN
+#include "common/filesystembase.h"
+#endif
 
 #include <csync_exclude.h>
 #include "vio/csync_vio_local.h"
@@ -305,7 +308,13 @@ void DiscoverySingleLocalDirectoryJob::run() {
         i.inode = dirent->inode;
         i.isDirectory = dirent->type == ItemTypeDirectory;
         i.isHidden = dirent->is_hidden;
-        i.isSymLink = dirent->type == ItemTypeSoftLink;
+#ifdef Q_OS_WIN
+        // exclude ".lnk" files as they are not essential, but, causing troubles when enabling the VFS due to QFileInfo::isDir() and other methods are freezing, which causes the ".lnk" files to start hydrating and freezing the app eventually.
+        const bool isWindowsShortcut = dirent->type == ItemTypeFile && FileSystem::isLnkFile(i.name);
+#else
+        const bool isWindowsShortcut = false;
+#endif
+        i.isSymLink = dirent->type == ItemTypeSoftLink || isWindowsShortcut;
         i.isVirtualFile = dirent->type == ItemTypeVirtualFile || dirent->type == ItemTypeVirtualFileDownload;
         i.type = dirent->type;
         results.push_back(i);
index d8b96cb41594b6b455de4c849d315e174afa5049..dcd75d46d0694c3903b55713f4f15816dd833f2f 100644 (file)
@@ -184,6 +184,8 @@ bool VfsCfApi::statTypeVirtualFile(csync_file_stat_t *stat, void *statData)
     const auto hasReparsePoint = (ffd->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
     const auto hasCloudTag = (ffd->dwReserved0 & IO_REPARSE_TAG_CLOUD) != 0;
 
+    const auto isWindowsShortcut = !isDirectory && FileSystem::isLnkFile(stat->path);
+
     // It's a dir with a reparse point due to the placeholder info (hence the cloud tag)
     // if we don't remove the reparse point flag the discovery will end up thinking
     // it is a file... let's prevent it
@@ -195,11 +197,9 @@ bool VfsCfApi::statTypeVirtualFile(csync_file_stat_t *stat, void *statData)
     } else if (isSparseFile && isPinned) {
         stat->type = ItemTypeVirtualFileDownload;
         return true;
-    } else if (!isSparseFile && isUnpinned){
-        if (!FileSystem::isLnkFile(stat->path)) {
-            stat->type = ItemTypeVirtualFileDehydration;
-            return true;
-        }
+    } else if (!isSparseFile && isUnpinned && !isWindowsShortcut){
+        stat->type = ItemTypeVirtualFileDehydration;
+        return true;
     } else if (isSparseFile) {
         stat->type = ItemTypeVirtualFile;
         return true;