summaryrefslogtreecommitdiffstats
path: root/common/clientapi.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-08 21:34:06 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-08 21:34:06 +0100
commit44744e281a56488c7ef257e12ca379ec4ceb2cdd (patch)
tree5fd45d6c6cf5e68ba2323fac3f498c6afa6f2ddf /common/clientapi.cpp
parentd82f0f6e52b601c3067ca70183458f5ce9b22c22 (diff)
downloadsink-44744e281a56488c7ef257e12ca379ec4ceb2cdd.tar.gz
sink-44744e281a56488c7ef257e12ca379ec4ceb2cdd.zip
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.
Diffstat (limited to 'common/clientapi.cpp')
-rw-r--r--common/clientapi.cpp22
1 files changed, 16 insertions, 6 deletions
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<void> Store::start(const QByteArray &identifier)
197 197
198void Store::removeFromDisk(const QByteArray &identifier) 198void Store::removeFromDisk(const QByteArray &identifier)
199{ 199{
200 //TODO By calling the resource executable with a --remove option instead 200 removeDataFromDisk(identifier).exec().waitForFinished();
201 //we can ensure that no other resource process is running at the same time 201}
202 QDir dir(Sink::storageLocation()); 202
203 for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { 203KAsync::Job<void> Store::removeDataFromDisk(const QByteArray &identifier)
204 Sink::Storage(Sink::storageLocation(), folder, Sink::Storage::ReadWrite).removeFromDisk(); 204{
205 } 205 //All databases are going to become invalid, nuke the environments
206 //TODO: all clients should react to a notification the resource
207 Sink::Storage::clearEnv();
208 Trace() << "Remove data from disk " << identifier;
209 auto time = QSharedPointer<QTime>::create();
210 time->start();
211 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier);
212 resourceAccess->open();
213 return resourceAccess->sendCommand(Sink::Commands::RemoveFromDiskCommand).then<void>([resourceAccess, time]() {
214 Trace() << "Remove from disk complete." << Log::TraceTime(time->elapsed());
215 });
206} 216}
207 217
208KAsync::Job<void> Store::synchronize(const Sink::Query &query) 218KAsync::Job<void> Store::synchronize(const Sink::Query &query)