//direct connection so the message box is blocking the sync.
connect(_engine.data(), &SyncEngine::aboutToRemoveAllFiles,
this, &Folder::slotAboutToRemoveAllFiles);
- connect(_engine.data(), &SyncEngine::aboutToRestoreBackup,
- this, &Folder::slotAboutToRestoreBackup);
connect(_engine.data(), &SyncEngine::transmissionProgress, this, &Folder::slotTransmissionProgress);
connect(_engine.data(), &SyncEngine::itemCompleted,
this, &Folder::slotItemCompleted);
}
}
-void Folder::slotAboutToRestoreBackup(bool *restore)
-{
- QString msg =
- tr("This sync would reset the files to an earlier time in the sync folder '%1'.\n"
- "This might be because a backup was restored on the server.\n"
- "Continuing the sync as normal will cause all your files to be overwritten by an older "
- "file in an earlier state. "
- "Do you want to keep your local most recent files as conflict files?");
- QMessageBox msgBox(QMessageBox::Warning, tr("Backup detected"),
- msg.arg(shortGuiLocalPath()));
- msgBox.setWindowFlags(msgBox.windowFlags() | Qt::WindowStaysOnTopHint);
- msgBox.addButton(tr("Normal Synchronisation"), QMessageBox::DestructiveRole);
- QPushButton *keepBtn = msgBox.addButton(tr("Keep Local Files as Conflict"), QMessageBox::AcceptRole);
-
- if (msgBox.exec() == -1) {
- *restore = true;
- return;
- }
- *restore = msgBox.clickedButton() == keepBtn;
-}
-
-
void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder)
{
settings.beginGroup(FolderMan::escapeAlias(folder.alias));
// connected to the corresponding signals in the SyncEngine
void slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *);
- void slotAboutToRestoreBackup(bool *);
-
/**
* Starts a sync operation
, _progressInfo(new ProgressInfo)
, _hasNoneFiles(false)
, _hasRemoveFile(false)
- , _hasForwardInTimeFiles(false)
- , _backInTimeFiles(0)
, _uploadLimit(0)
, _downloadLimit(0)
, _anotherSyncNeeded(NoFollowUpSync)
// An upload of an existing file means that the file was left unchanged on the server
// This counts as a NONE for detecting if all the files on the server were changed
_hasNoneFiles = true;
- } else if (!item->isDirectory()) {
- auto difftime = std::difftime(item->_modtime, item->_previousModtime);
- if (difftime < -3600 * 2) {
- // We are going back on time
- // We only increment if the difference is more than two hours to avoid clock skew
- // issues or DST changes. (We simply ignore files that goes in the past less than
- // two hours for the backup detection heuristics.)
- _backInTimeFiles++;
- qCWarning(lcEngine) << item->_file << "has a timestamp earlier than the local file";
- } else if (difftime > 0) {
- _hasForwardInTimeFiles = true;
- }
}
}
_hasNoneFiles = false;
_hasRemoveFile = false;
- _hasForwardInTimeFiles = false;
- _backInTimeFiles = 0;
_seenFiles.clear();
_progressInfo->reset();
* Set *cancel to true in a slot connected from this signal to abort the sync.
*/
void aboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel);
- /**
- * Emited when the sync engine detects that all the files are changed to dates in the past.
- * This usually happen when a backup was restored on the server from an earlier date.
- * Set *restore to true in a slot connected from this signal to re-upload all files.
- */
- void aboutToRestoreBackup(bool *restore);
// A new folder was discovered and was not synced because of the confirmation feature
void newBigFolder(const QString &folder, bool isExternal);
// true if there is at leasr one file with instruction REMOVE
bool _hasRemoveFile;
- // true if there is at least one file from the server that goes forward in time
- bool _hasForwardInTimeFiles;
-
- // number of files which goes back in time from the server
- int _backInTimeFiles;
-
// If ignored files should be ignored
bool _ignore_hidden_files = false;