diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-07-05 14:26:54 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-07-06 13:01:00 +0300 |
commit | 68c68cbd8dcba0353cc39b4ed3864fe0cd9e083b (patch) | |
tree | 3be77fb5d905afe1f84e2c72dff3abeff4b8a439 /src | |
parent | 0097f76eaaa74a9f4dd0f7a76d0080160862ac6b (diff) |
qCmd: Implement aboutToRemoveAllFiles
Fixes: #8804
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/cmd.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index c26212aae..3f4a48a09 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -167,11 +167,40 @@ void sync(const SyncCTX &ctx) } } }); + QObject::connect(engine, &SyncEngine::aboutToRemoveAllFiles, engine, [ctx](OCC::SyncFileItem::Direction dir, std::function<void(bool)> callback) { + if (!ctx.options.interactive) { + callback(false); + } else { + std::cout << (dir == SyncFileItem::Down ? "All files in the sync folder '%1' folder were deleted on the server.\n" + "These deletes will be synchronized to your local sync folder, making such files " + "unavailable unless you have a right to restore. \n" + "If you decide to keep the files, they will be re-synced with the server if you have rights to do so.\n" + "If you decide to delete the files, they will be unavailable to you, unless you are the owner." + : "All the files in your local sync folder '%1' were deleted. These deletes will be " + "synchronized with your server, making such files unavailable unless restored.\n" + "Are you sure you want to sync those actions with the server?\n" + "If this was an accident and you decide to keep your files, they will be re-synced from the server.") + << std::endl; + std::string s; + while (true) { + std::cout << "Remove all files?[y,n]"; + std::getline(std::cin, s); + if (s == "y") { + callback(false); + } else if (s == "n") { + callback(true); + } else { + continue; + } + return; + } + } + }); + QObject::connect(engine, &SyncEngine::syncError, engine, + [](const QString &error) { qWarning() << "Sync error:" << error; }); engine->setSyncOptions(opt); engine->setIgnoreHiddenFiles(ctx.options.ignoreHiddenFiles); engine->setNetworkLimits(ctx.options.uplimit, ctx.options.downlimit); - QObject::connect(engine, &SyncEngine::syncError, engine, - [](const QString &error) { qWarning() << "Sync error:" << error; }); // Exclude lists |