diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index fdd3ac602eb..59af6a9ad56 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -923,7 +923,12 @@ void Folder::startSync() Q_ASSERT(_folderWatcher); if (!OC_ENSURE(!isSyncRunning())) { - qCCritical(lcFolder) << "ERROR csync is still running and new sync requested."; + qCCritical(lcFolder) << "ERROR sync is still running and new sync requested."; + return; + } + + if (!OC_ENSURE(canSync())) { + qCCritical(lcFolder) << "ERROR folder is currently not sync able."; return; } @@ -1243,6 +1248,10 @@ bool Folder::virtualFilesEnabled() const void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction) { + if (_removeAllFilesDialog) { + ocApp()->gui()->raiseDialog(_removeAllFilesDialog); + return; + } const QString msg = [direction] { if (direction == SyncFileItem::Down) { return tr("All files in the sync folder '%1' folder were deleted on the server.\n" @@ -1257,16 +1266,16 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction) "If this was an accident and you decide to keep your files, they will be re-synced from the server."); } }(); - auto msgBox = new QMessageBox(QMessageBox::Warning, tr("Remove All Files?"), - msg.arg(shortGuiLocalPath()), QMessageBox::NoButton, ocApp()->gui()->settingsDialog()); - msgBox->setAttribute(Qt::WA_DeleteOnClose); - msgBox->setWindowFlags(msgBox->windowFlags() | Qt::WindowStaysOnTopHint); - msgBox->addButton(tr("Remove all files"), QMessageBox::DestructiveRole); - QPushButton *keepBtn = msgBox->addButton(tr("Keep files"), QMessageBox::AcceptRole); - msgBox->setDefaultButton(keepBtn); + _removeAllFilesDialog = + new QMessageBox(QMessageBox::Warning, tr("Remove All Files?"), msg.arg(shortGuiLocalPath()), QMessageBox::NoButton, ocApp()->gui()->settingsDialog()); + _removeAllFilesDialog->setAttribute(Qt::WA_DeleteOnClose); + _removeAllFilesDialog->setWindowFlags(_removeAllFilesDialog->windowFlags() | Qt::WindowStaysOnTopHint); + _removeAllFilesDialog->addButton(tr("Remove all files"), QMessageBox::DestructiveRole); + QPushButton *keepBtn = _removeAllFilesDialog->addButton(tr("Keep files"), QMessageBox::AcceptRole); + _removeAllFilesDialog->setDefaultButton(keepBtn); setSyncPaused(true); - connect(msgBox, &QMessageBox::finished, this, [msgBox, keepBtn, this] { - if (msgBox->clickedButton() == keepBtn) { + connect(_removeAllFilesDialog, &QMessageBox::finished, this, [keepBtn, this] { + if (_removeAllFilesDialog->clickedButton() == keepBtn) { // reset the db upload all local files or download all remote files FileSystem::setFolderMinimumPermissions(path()); // will remove placeholders in the next sync @@ -1278,11 +1287,13 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction) _allowRemoveAllOnce = true; // the only way we end up in here is that the folder was not paused setSyncPaused(false); - FolderMan::instance()->scheduler()->enqueueFolder(this); + if (canSync()) { + FolderMan::instance()->scheduler()->enqueueFolder(this); + } }); - connect(this, &Folder::destroyed, msgBox, &QMessageBox::deleteLater); - msgBox->open(); - ownCloudGui::raiseDialog(msgBox); + connect(this, &Folder::destroyed, _removeAllFilesDialog, &QMessageBox::deleteLater); + _removeAllFilesDialog->open(); + ownCloudGui::raiseDialog(_removeAllFilesDialog); } FolderDefinition::FolderDefinition(const QByteArray &id, const QUrl &davUrl, const QString &spaceId, const QString &displayName) diff --git a/src/gui/folder.h b/src/gui/folder.h index 51c5ef1fa67..002b3fd3f3c 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -529,6 +529,8 @@ private slots: */ QSharedPointer _vfs; + QPointer _removeAllFilesDialog; + // allow that all files are removed in the next run bool _allowRemoveAllOnce = false; diff --git a/src/gui/scheduling/etagwatcher.cpp b/src/gui/scheduling/etagwatcher.cpp index fa6a8640f2a..d13e3e6ed8f 100644 --- a/src/gui/scheduling/etagwatcher.cpp +++ b/src/gui/scheduling/etagwatcher.cpp @@ -80,7 +80,7 @@ void ETagWatcher::updateEtag(Folder *f, const QString &etag) // https://github.com/owncloud/ocis/issues/7160 if (OC_ENSURE_NOT(etag.isEmpty())) { auto &info = _lastEtagJob[f]; - if (info.etag != etag) { + if (f->canSync() && info.etag != etag) { info.etag = etag; _folderMan->scheduler()->enqueueFolder(f); } diff --git a/src/gui/scheduling/syncscheduler.cpp b/src/gui/scheduling/syncscheduler.cpp index d9405ffca10..7582ad8ff51 100644 --- a/src/gui/scheduling/syncscheduler.cpp +++ b/src/gui/scheduling/syncscheduler.cpp @@ -145,7 +145,7 @@ void SyncScheduler::startNext() [this](const SyncResult &result) { if (result.status() != SyncResult::Success) { // Retry a couple of times after failure; or regularly if requested - if ((_currentSync->consecutiveFailingSyncs() > 0 && _currentSync->consecutiveFailingSyncs() < 3) + if (_currentSync->canSync() && (_currentSync->consecutiveFailingSyncs() > 0 && _currentSync->consecutiveFailingSyncs() < 3) || _currentSync->syncEngine().isAnotherSyncNeeded() == AnotherSyncNeeded::DelayedFollowUp) { QTimer::singleShot(SyncEngine::minimumFileAgeForUpload, this, [folder = _currentSync, this] { enqueueFolder(folder); }); }