]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Properly check folder size on server
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 3 Jul 2023 17:21:03 +0000 (01:21 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 4 Aug 2023 09:40:37 +0000 (17:40 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/libsync/discovery.cpp
src/libsync/discoveryphase.cpp
src/libsync/discoveryphase.h

index e9bbe46b6bfbf9b80aee79f83ad6314244e1d1eb..3205580eeb3ef71b901c93a7ab3852003ba02cb7 100644 (file)
@@ -703,6 +703,11 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it
         const auto sizeOnServer = isVirtualE2EePlaceholder ? serverEntry.size - Constants::e2EeTagSize : serverEntry.size;
         const auto metaDataSizeNeedsUpdateForE2EeFilePlaceholder = isVirtualE2EePlaceholder && dbEntry._fileSize == serverEntry.size;
 
+        if (serverEntry.isDirectory) {
+            // Even if over quota, continue syncing as normal for now
+            _discoveryData->checkSelectiveSyncExistingFolder(path._server);
+        }
+
         if (serverEntry.isDirectory != dbEntry.isDirectory()) {
             // If the type of the entity changed, it's like NEW, but
             // needs to delete the other entity first.
@@ -718,19 +723,12 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it
             item->_instruction = CSYNC_INSTRUCTION_SYNC;
             item->_type = ItemTypeVirtualFileDownload;
         } else if (dbEntry._etag != serverEntry.etag) {
-            const auto differingSize = sizeOnServer != item->_size;
-
             item->_direction = SyncFileItem::Down;
             item->_modtime = serverEntry.modtime;
             item->_size = sizeOnServer;
 
             if (serverEntry.isDirectory) {
                 ENFORCE(dbEntry.isDirectory());
-
-                if (differingSize) {
-                    _discoveryData->checkSelectiveSyncExistingFolder(path._server, sizeOnServer);
-                }
-
                 item->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
             } else if (!localEntry.isValid() && _queryLocal != ParentNotChanged) {
                 // Deleted locally, changed on server
@@ -743,7 +741,8 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it
                                  << "serverEntry.isDirectory:" << serverEntry.isDirectory
                                  << "dbEntry.isDirectory:" << dbEntry.isDirectory();
             }
-        } else if (dbEntry._modtime != serverEntry.modtime && localEntry.size == serverEntry.size && dbEntry._fileSize == serverEntry.size && dbEntry._etag == serverEntry.etag) {
+        } else if (dbEntry._modtime != serverEntry.modtime && localEntry.size == serverEntry.size && dbEntry._fileSize == serverEntry.size
+                   && dbEntry._etag == serverEntry.etag) {
             item->_direction = SyncFileItem::Down;
             item->_modtime = serverEntry.modtime;
             item->_size = sizeOnServer;
index 68aaf6c0c57d88f538718148d3644e862f2f921c..8f2f1e7c88a8b027b0647f7e207b67f83d063203 100644 (file)
@@ -150,15 +150,20 @@ void DiscoveryPhase::checkSelectiveSyncNewFolder(const QString &path,
     });
 }
 
-void DiscoveryPhase::checkSelectiveSyncExistingFolder(const QString &path, const qint64 folderSize)
+void DiscoveryPhase::checkSelectiveSyncExistingFolder(const QString &path)
 {
     // TODO: Check for setting to obey big folder sync
     // If no size limit is enforced, or if is in whitelist (explicitly allowed) or in blacklist (explicitly disallowed), do nothing.
     if (!activeFolderSizeLimit() || findPathInList(_selectiveSyncWhiteList, path) || findPathInList(_selectiveSyncBlackList, path)) {
         return;
-    } else if (folderSize >= _syncOptions._newBigFolderSizeLimit) { // If the folder is too big, notify the user and prompt for response.
-        emit existingFolderNowBig(path);
     }
+
+    checkFolderSizeLimit(path, [this, path](const bool bigFolder) {
+        if (bigFolder) {
+            // Notify the user and prompt for response.
+            emit existingFolderNowBig(path);
+        }
+    });
 }
 
 /* Given a path on the remote, give the path as it is when the rename is done */
index 1775325a61fcefce3b379ad8c4fd965e5774e842..dce4261e8202093be0ff9ee0599282ff589fafdf 100644 (file)
@@ -266,7 +266,7 @@ class DiscoveryPhase : public QObject
                                      const RemotePermissions rp,
                                      const std::function<void(bool)> callback);
 
-    void checkSelectiveSyncExistingFolder(const QString &path, const qint64 folderSize);
+    void checkSelectiveSyncExistingFolder(const QString &path);
 
     /** Given an original path, return the target path obtained when renaming is done.
      *