Merge pull request #4903 from nextcloud/bugfix/selective-sync-abort-error

Bugfix/selective sync abort error
This commit is contained in:
allexzander 2022-09-07 15:31:23 +03:00 committed by GitHub
commit 926256df97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 7 deletions

View File

@ -643,6 +643,12 @@ void FolderMan::scheduleFolder(Folder *f)
startScheduledSyncSoon();
}
void FolderMan::scheduleFolderForImmediateSync(Folder *f)
{
_nextSyncShouldStartImmediately = true;
scheduleFolder(f);
}
void FolderMan::scheduleFolderNext(Folder *f)
{
auto alias = f->alias();
@ -792,6 +798,12 @@ void FolderMan::startScheduledSyncSoon()
// Time since the last sync run counts against the delay
msDelay = qMax(1ll, msDelay - msSinceLastSync);
if (_nextSyncShouldStartImmediately) {
_nextSyncShouldStartImmediately = false;
qCInfo(lcFolderMan) << "Next sync is marked to start immediately, so setting the delay to '0'";
msDelay = 0;
}
qCInfo(lcFolderMan) << "Starting the next scheduled sync in" << (msDelay / 1000) << "seconds";
_startScheduledSyncTimer.start(msDelay);
}

View File

@ -193,6 +193,9 @@ public:
/** Queues a folder for syncing. */
void scheduleFolder(Folder *);
/** Queues a folder for syncing that starts immediately. */
void scheduleFolderForImmediateSync(Folder *);
/** Puts a folder in the very front of the queue. */
void scheduleFolderNext(Folder *);
@ -357,6 +360,8 @@ private:
/// Picks the next scheduled folder and starts the sync
QTimer _startScheduledSyncTimer;
bool _nextSyncShouldStartImmediately = false;
QScopedPointer<SocketApi> _socketApi;
NavigationPaneHelper _navigationPaneHelper;

View File

@ -931,7 +931,7 @@ void FolderStatusModel::slotApplySelectiveSync()
folder->journalDb()->schedulePathForRemoteDiscovery(it);
folder->schedulePathForLocalDiscovery(it);
}
FolderMan::instance()->scheduleFolder(folder);
FolderMan::instance()->scheduleFolderForImmediateSync(folder);
}
}

View File

@ -544,7 +544,7 @@ void SelectiveSyncDialog::accept()
_folder->schedulePathForLocalDiscovery(it);
}
folderMan->scheduleFolder(_folder);
folderMan->scheduleFolderForImmediateSync(_folder);
}
QDialog::accept();
}

View File

@ -482,6 +482,8 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
{
Q_ASSERT(std::is_sorted(items.begin(), items.end()));
_abortRequested = false;
/* This builds all the jobs needed for the propagation.
* Each directory is a PropagateDirectory job, which contains the files in it.
* In order to do that we loop over the items. (which are sorted by destination)

View File

@ -538,6 +538,8 @@ public:
{
if (_abortRequested)
return;
_abortRequested = true;
if (_rootJob) {
// Connect to abortFinished which signals that abort has been asynchronously finished
connect(_rootJob.data(), &PropagateDirectory::abortFinished, this, &OwncloudPropagator::emitFinished);
@ -633,6 +635,7 @@ private slots:
{
if (!_finishedEmited)
emit finished(status == SyncFileItem::Success);
_abortRequested = false;
_finishedEmited = true;
}

View File

@ -1056,19 +1056,16 @@ void SyncEngine::switchToVirtualFiles(const QString &localPath, SyncJournalDb &j
void SyncEngine::abort()
{
if (_propagator)
qCInfo(lcEngine) << "Aborting sync";
if (_propagator) {
// If we're already in the propagation phase, aborting that is sufficient
qCInfo(lcEngine) << "Aborting sync in propagator...";
_propagator->abort();
} else if (_discoveryPhase) {
// Delete the discovery and all child jobs after ensuring
// it can't finish and start the propagator
disconnect(_discoveryPhase.data(), nullptr, this, nullptr);
_discoveryPhase.take()->deleteLater();
Q_EMIT syncError(tr("Synchronization will resume shortly."));
qCInfo(lcEngine) << "Aborting sync in discovery...";
finalize(false);
}
}