From 7ed3ecd282516296bbc7e4a2a24d1e3266bd8601 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 25 May 2016 10:21:36 +0200 Subject: Maildir folder inspection --- examples/maildirresource/maildirresource.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'examples') diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 6dc9990..e1e4d95 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp @@ -531,7 +531,11 @@ KAsync::Job MaildirResource::inspect(int inspectionType, const QByteArray } if (domainType == ENTITY_TYPE_FOLDER) { const auto remoteId = resolveLocalId(ENTITY_TYPE_FOLDER, entityId, synchronizationTransaction); + auto mainDatabase = Sink::Storage::mainDatabase(transaction, ENTITY_TYPE_FOLDER); + auto bufferAdaptor = getLatest(mainDatabase, entityId, *mMailAdaptorFactory); + Q_ASSERT(bufferAdaptor); + const Sink::ApplicationDomain::Folder folder(mResourceInstanceIdentifier, entityId, 0, bufferAdaptor); if (inspectionType == Sink::ResourceControl::Inspection::CacheIntegrityInspectionType) { if (!QDir(remoteId).exists()) { return KAsync::error(1, "The directory is not existing: " + remoteId); @@ -551,6 +555,14 @@ KAsync::Job MaildirResource::inspect(int inspectionType, const QByteArray if (list.size() != expectedCount) { return KAsync::error(1, QString("Wrong number of files; found %1 instead of %2.").arg(list.size()).arg(expectedCount)); } + if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { + if (!remoteId.endsWith(folder.getName().toUtf8())) { + return KAsync::error(1, "Wrong folder name: " + remoteId); + } + if (QDir(remoteId).exists() != expectedValue.toBool()) { + return KAsync::error(1, "Wrong folder existence: " + remoteId); + } + } } } return KAsync::null(); -- cgit v1.2.3