New Discovery algorithm: Remove the sync cleanup phase

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.
This commit is contained in:
Olivier Goffart 2018-10-09 15:54:42 +02:00 committed by Kevin Ottens
parent 35c0cf4e59
commit c8eff3da2d
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
4 changed files with 1 additions and 73 deletions

View file

@ -1161,57 +1161,6 @@ bool SyncJournalDb::getFilesBelowPath(const QByteArray &path, const std::functio
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);

View file

@ -184,9 +184,6 @@ public:
*/
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.
*/

View file

@ -417,7 +417,6 @@ void SyncEngine::startSync()
_hasForwardInTimeFiles = false;
_backInTimeFiles = 0;
_seenFiles.clear();
_temporarilyUnavailablePaths.clear();
_progressInfo->reset();
@ -812,10 +811,6 @@ void SyncEngine::slotFinished(bool success)
_journal->setDataFingerprint(_discoveryPhase->_dataFingerprint);
}
if (success && !_journal->postSyncCleanup(_seenFiles, _temporarilyUnavailablePaths)) {
qCDebug(lcEngine) << "Cleaning of synced ";
}
conflictRecordMaintenance();
_journal->commit("All Finished.", false);
@ -844,7 +839,6 @@ void SyncEngine::finalize(bool success)
// Delete the propagator only after emitting the signal.
_propagator.clear();
_seenFiles.clear();
_temporarilyUnavailablePaths.clear();
_uniqueErrors.clear();
_localDiscoveryPaths.clear();
_localDiscoveryStyle = LocalDiscoveryStyle::FilesystemOnly;

View file

@ -231,21 +231,9 @@ private:
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;