Skip to content

Commit

Permalink
also include temporary files from WAL SQLite mode into debug archive
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mgallien committed Aug 28, 2024
1 parent 749773f commit ba872a0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,24 @@ ZipEntry fileInfoToLogZipEntry(const QFileInfo &info)
return entry;
}

ZipEntry syncFolderToZipEntry(OCC::Folder *f)
QVector<ZipEntry> syncFolderToDatabaseZipEntry(OCC::Folder *f)

Check warning on line 70 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.cpp:70:19 [modernize-use-trailing-return-type]

use a trailing return type for this function
{
QVector<ZipEntry> result;

Check warning on line 72 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.cpp:72:23 [cppcoreguidelines-init-variables]

variable 'result' is not initialized

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()
Expand All @@ -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;
}
Expand Down

0 comments on commit ba872a0

Please sign in to comment.