From 44744e281a56488c7ef257e12ca379ec4ceb2cdd Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 8 Feb 2016 21:34:06 +0100 Subject: Executed database removal in the resource instead of the client. The resource doesn't really notify all clients properly about the removal, but the tests all still pass. --- common/clientapi.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'common/clientapi.cpp') diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 5eb4b55..73bc194 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp @@ -197,12 +197,22 @@ KAsync::Job Store::start(const QByteArray &identifier) void Store::removeFromDisk(const QByteArray &identifier) { - //TODO By calling the resource executable with a --remove option instead - //we can ensure that no other resource process is running at the same time - QDir dir(Sink::storageLocation()); - for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { - Sink::Storage(Sink::storageLocation(), folder, Sink::Storage::ReadWrite).removeFromDisk(); - } + removeDataFromDisk(identifier).exec().waitForFinished(); +} + +KAsync::Job Store::removeDataFromDisk(const QByteArray &identifier) +{ + //All databases are going to become invalid, nuke the environments + //TODO: all clients should react to a notification the resource + Sink::Storage::clearEnv(); + Trace() << "Remove data from disk " << identifier; + auto time = QSharedPointer::create(); + time->start(); + auto resourceAccess = QSharedPointer::create(identifier); + resourceAccess->open(); + return resourceAccess->sendCommand(Sink::Commands::RemoveFromDiskCommand).then([resourceAccess, time]() { + Trace() << "Remove from disk complete." << Log::TraceTime(time->elapsed()); + }); } KAsync::Job Store::synchronize(const Sink::Query &query) -- cgit v1.2.3