From 49b1c5c3b342a84ec71e9b7dfd06a80b6d6e6c96 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 10 Dec 2015 10:29:12 +0100 Subject: Remove all databases from disk --- common/clientapi.cpp | 13 ++++++++++++- common/clientapi.h | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 255ea21..061d920 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp @@ -24,17 +24,18 @@ #include #include #include +#include #include #include #include "resourceaccess.h" #include "commands.h" #include "resourcefacade.h" -#include "log.h" #include "definitions.h" #include "resourceconfig.h" #include "facadefactory.h" #include "modelresult.h" +#include "storage.h" #include "log.h" namespace Akonadi2 @@ -178,6 +179,16 @@ 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(Akonadi2::storageLocation()); + for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { + Akonadi2::Storage(Akonadi2::storageLocation(), folder, Akonadi2::Storage::ReadWrite).removeFromDisk(); + } +} + KAsync::Job Store::synchronize(const Akonadi2::Query &query) { Trace() << "synchronize"; diff --git a/common/clientapi.h b/common/clientapi.h index 074aabc..3d9095d 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -93,6 +93,11 @@ public: * Synchronize data to local cache. */ static KAsync::Job synchronize(const Akonadi2::Query &query); + + /** + * Removes a resource from disk. + */ + static void removeFromDisk(const QByteArray &resourceIdentifier); }; -- cgit v1.2.3