From ba872a0fb0117efe2a21e5d88cad44ff61253d10 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 14 Aug 2024 16:20:10 +0200 Subject: [PATCH] also include temporary files from WAL SQLite mode into debug archive should make sure that the debug archive has a correct up to date view of the sync client database Signed-off-by: Matthieu Gallien --- src/gui/generalsettings.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 225b6451cde2..6af68b396cbe 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -67,11 +67,24 @@ ZipEntry fileInfoToLogZipEntry(const QFileInfo &info) return entry; } -ZipEntry syncFolderToZipEntry(OCC::Folder *f) +QVector syncFolderToDatabaseZipEntry(OCC::Folder *f) { + QVector 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 createDebugArchiveFileList() @@ -94,9 +107,11 @@ QVector 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; }