SyncEngine: Save a bit of memory by not keeping a set of all filename
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 14 Oct 2019 11:19:41 +0000 (13:19 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:01 +0000 (10:59 +0100)
This is only used for conflict files, so only save conflict files.
(The _seenFile was used for other things in 2.5, but not anymore)

src/libsync/syncengine.cpp
src/libsync/syncengine.h

index 806e92c23b37999357e782ab7469e1571cdf9878..bb2a83a25bbd50fa4a04ca246108f5ce6e3ca655 100644 (file)
@@ -285,9 +285,8 @@ void SyncEngine::conflictRecordMaintenance()
     //
     // This happens when the conflicts table is new or when conflict files
     // are downlaoded but the server doesn't send conflict headers.
-    for (const auto &path : qAsConst(_seenFiles)) {
-        if (!Utility::isConflictFile(path))
-            continue;
+    for (const auto &path : qAsConst(_seenConflictFiles)) {
+        ASSERT(Utility::isConflictFile(path));
 
         auto bapath = path.toUtf8();
         if (!conflictRecordPaths.contains(bapath)) {
@@ -310,11 +309,8 @@ void SyncEngine::conflictRecordMaintenance()
 
 void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
 {
-    _seenFiles.insert(item->_file);
-    if (!item->_renameTarget.isEmpty()) {
-        // Yes, this records both the rename renameTarget and the original so we keep both in case of a rename
-        _seenFiles.insert(item->_renameTarget);
-    }
+    if (Utility::isConflictFile(item->_file))
+        _seenConflictFiles.insert(item->_file);
     if (item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA && !item->isDirectory()) {
         // For directories, metadata-only updates will be done after all their files are propagated.
 
@@ -441,7 +437,7 @@ void SyncEngine::startSync()
 
     _hasNoneFiles = false;
     _hasRemoveFile = false;
-    _seenFiles.clear();
+    _seenConflictFiles.clear();
 
     _progressInfo->reset();
 
@@ -881,7 +877,7 @@ void SyncEngine::finalize(bool success)
 
     // Delete the propagator only after emitting the signal.
     _propagator.clear();
-    _seenFiles.clear();
+    _seenConflictFiles.clear();
     _uniqueErrors.clear();
     _localDiscoveryPaths.clear();
     _localDiscoveryStyle = LocalDiscoveryStyle::FilesystemOnly;
index 4bb1fe1228578c73ec6302a7a9ceaa1a20b8aa9d..9e23afe880feffe349fc9f7bd224673d478cdd81 100644 (file)
@@ -240,8 +240,8 @@ private:
     QScopedPointer<DiscoveryPhase> _discoveryPhase;
     QSharedPointer<OwncloudPropagator> _propagator;
 
-    // List of all files we seen
-    QSet<QString> _seenFiles;
+    // List of all files with conflicts
+    QSet<QString> _seenConflictFiles;
 
     QScopedPointer<ProgressInfo> _progressInfo;