From 254f9dad6377311b8115221c252b20726acad0c5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 11 May 2017 17:47:54 +0200 Subject: Upgrade job that we can eventually use to upgrade the storage --- common/store.cpp | 13 +++++++++++++ common/store.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) (limited to 'common') diff --git a/common/store.cpp b/common/store.cpp index d266098..0eefe69 100644 --- a/common/store.cpp +++ b/common/store.cpp @@ -277,6 +277,19 @@ KAsync::Job Store::removeDataFromDisk(const QByteArray &identifier) }); } +KAsync::Job Store::upgrade() +{ + SinkLog() << "Upgrading..."; + return fetchAll({}) + .template each([](const ApplicationDomain::SinkResource::Ptr &resource) -> KAsync::Job { + SinkLog() << "Removing caches for " << resource->identifier(); + return removeDataFromDisk(resource->identifier()); + }) + .then([] { + SinkLog() << "Upgrade complete."; + }); +} + static KAsync::Job synchronize(const QByteArray &resource, const Sink::SyncScope &scope) { SinkLog() << "Synchronizing " << resource << scope; diff --git a/common/store.h b/common/store.h index fae76e5..34e14df 100644 --- a/common/store.h +++ b/common/store.h @@ -122,6 +122,18 @@ KAsync::Job SINK_EXPORT synchronize(const Sink::SyncScope &query); */ KAsync::Job SINK_EXPORT removeDataFromDisk(const QByteArray &resourceIdentifier); +/** + * Run upgrade jobs. + * + * Run this to upgrade your local database to a new version. + * Note that this may: + * * take a while + * * remove some/all of your local caches + * + * Note: The initial implementation simply calls removeDataFromDisk for all resources. + */ +KAsync::Job SINK_EXPORT upgrade(); + template KAsync::Job SINK_EXPORT fetchOne(const Sink::Query &query); -- cgit v1.2.3