Since we do not recurse within some directories, many files are not seen.
The stale entry will cleanup by themself as the sync engine try to remove
the files that are already removed.
Should we need to actually do this cleanup, it should be dotected in the
discovery.
return true;
}
-bool SyncJournalDb::postSyncCleanup(const QSet<QString> &filepathsToKeep,
- const QSet<QString> &prefixesToKeep)
-{
- QMutexLocker locker(&_mutex);
-
- if (!checkConnect()) {
- return false;
- }
-
- SqlQuery query(_db);
- query.prepare("SELECT phash, path, e2eMangledName FROM metadata order by path");
-
- if (!query.exec()) {
- return false;
- }
-
- QByteArrayList superfluousItems;
-
- while (query.next()) {
- const auto file = QString(query.baValue(1));
- const auto mangledPath = QString(query.baValue(2));
- bool keep = filepathsToKeep.contains(file) || filepathsToKeep.contains(mangledPath);
- if (!keep) {
- foreach (const QString &prefix, prefixesToKeep) {
- if (file.startsWith(prefix) || mangledPath.startsWith(prefix)) {
- keep = true;
- break;
- }
- }
- }
- if (!keep) {
- superfluousItems.append(query.baValue(0));
- }
- }
-
- if (superfluousItems.count()) {
- QByteArray sql = "DELETE FROM metadata WHERE phash in (" + superfluousItems.join(",") + ")";
- qCInfo(lcDb) << "Sync Journal cleanup for" << superfluousItems;
- SqlQuery delQuery(_db);
- delQuery.prepare(sql);
- if (!delQuery.exec()) {
- return false;
- }
- }
-
- // Incorporate results back into main DB
- walCheckpoint();
-
- return true;
-}
-
int SyncJournalDb::getFileRecordCount()
{
QMutexLocker locker(&_mutex);
*/
void forceRemoteDiscoveryNextSync();
- bool postSyncCleanup(const QSet<QString> &filepathsToKeep,
- const QSet<QString> &prefixesToKeep);
-
/* Because sqlite transactions are really slow, we encapsulate everything in big transactions
* Commit will actually commit the transaction and create a new one.
*/
_hasForwardInTimeFiles = false;
_backInTimeFiles = 0;
_seenFiles.clear();
- _temporarilyUnavailablePaths.clear();
_progressInfo->reset();
_journal->setDataFingerprint(_discoveryPhase->_dataFingerprint);
}
- if (success && !_journal->postSyncCleanup(_seenFiles, _temporarilyUnavailablePaths)) {
- qCDebug(lcEngine) << "Cleaning of synced ";
- }
-
conflictRecordMaintenance();
_journal->commit("All Finished.", false);
// Delete the propagator only after emitting the signal.
_propagator.clear();
_seenFiles.clear();
- _temporarilyUnavailablePaths.clear();
_uniqueErrors.clear();
_localDiscoveryPaths.clear();
_localDiscoveryStyle = LocalDiscoveryStyle::FilesystemOnly;
QScopedPointer<DiscoveryPhase> _discoveryPhase;
QSharedPointer<OwncloudPropagator> _propagator;
- // After a sync, only the syncdb entries whose filenames appear in this
- // set will be kept. See _temporarilyUnavailablePaths.
+ // List of all files we seen
QSet<QString> _seenFiles;
- // Some paths might be temporarily unavailable on the server, for
- // example due to 503 Storage not available. Deleting information
- // about the files from the database in these cases would lead to
- // incorrect synchronization.
- // Therefore all syncdb entries whose filename starts with one of
- // the paths in this set will be kept.
- // The specific case that fails otherwise is deleting a local file
- // while the remote says storage not available.
- QSet<QString> _temporarilyUnavailablePaths;
-
-
QScopedPointer<ProgressInfo> _progressInfo;
QScopedPointer<ExcludedFiles> _excludedFiles;