also include temporary files from WAL SQLite mode into debug archive
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 14 Aug 2024 14:20:10 +0000 (16:20 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Wed, 28 Aug 2024 09:36:33 +0000 (11:36 +0200)
should make sure that the debug archive has a correct up to date view of
the sync client database

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/generalsettings.cpp

index 225b6451cde2f4c5e3fd29105795cd69a8d71f01..6af68b396cbe8d357ee13daf73b8a1a9205b6914 100644 (file)
@@ -67,11 +67,24 @@ ZipEntry fileInfoToLogZipEntry(const QFileInfo &info)
     return entry;
 }
 
-ZipEntry syncFolderToZipEntry(OCC::Folder *f)
+QVector<ZipEntry> syncFolderToDatabaseZipEntry(OCC::Folder *f)
 {
+    QVector<ZipEntry> result;
+
     const auto journalPath = f->journalDb()->databaseFilePath();
     const auto journalInfo = QFileInfo(journalPath);
-    return fileInfoToZipEntry(journalInfo);
+    const auto walJournalInfo = QFileInfo(journalPath + "-wal");
+    const auto shmJournalInfo = QFileInfo(journalPath + "-shm");
+
+    result += fileInfoToZipEntry(journalInfo);
+    if (walJournalInfo.exists()) {
+        result += fileInfoToZipEntry(walJournalInfo);
+    }
+    if (shmJournalInfo.exists()) {
+        result += fileInfoToZipEntry(shmJournalInfo);
+    }
+
+    return result;
 }
 
 QVector<ZipEntry> createDebugArchiveFileList()
@@ -94,9 +107,11 @@ QVector<ZipEntry> createDebugArchiveFileList()
     }
 
     const auto folders = OCC::FolderMan::instance()->map().values();
-    std::transform(std::cbegin(folders), std::cend(folders),
-                   std::back_inserter(list),
-                   syncFolderToZipEntry);
+    std::for_each(std::cbegin(folders), std::cend(folders),
+                  [&list] (auto &folderIt) {
+                      const auto &newEntries = syncFolderToDatabaseZipEntry(folderIt);
+                      std::copy(std::cbegin(newEntries), std::cend(newEntries), std::back_inserter(list));
+                  });
 
     return list;
 }