side += it->_direction == SyncFileItem::Down ? 1 : -1;
}
}
- emit aboutToRemoveAllFiles(side >= 0 ? SyncFileItem::Down : SyncFileItem::Up, [this, finish](bool cancel){
+
+ QPointer<QObject> guard = new QObject();
+ auto callback = [this, finish, guard](bool cancel) -> void {
+ // use a guard to ensure its only called once...
+ if (!guard)
+ {
+ return;
+ }
+ guard->deleteLater();
if (cancel) {
qCInfo(lcEngine) << "User aborted sync";
finalize(false);
} else {
finish();
}
- });
+ };
+ emit aboutToRemoveAllFiles(side >= 0 ? SyncFileItem::Down : SyncFileItem::Up, callback);
return;
}
finish();
#include <memory>
#include <cookiejar.h>
+#include <QTimer>
/*
* TODO: In theory we should use QVERIFY instead of Q_ASSERT for testing, but this
// Ignore temporary files from the download. (This is in the default exclude list, but we don't load it)
_syncEngine->excludedFiles().addManualExclude("]*.~*");
+ // handle aboutToRemoveAllFiles with a timeout in case our test does not handle it
+ QObject::connect(_syncEngine.get(), &OCC::SyncEngine::aboutToRemoveAllFiles, _syncEngine.get(), [this](OCC::SyncFileItem::Direction, std::function<void(bool)> callback){
+ QTimer::singleShot(1 * 1000, _syncEngine.get(), [callback]{
+ callback(false);
+ });
+ });
+
// Ensure we have a valid VfsOff instance "running"
switchToVfs(_syncEngine->syncOptions()._vfs);