From 1e2e4437094d80f1cdd849c7341019910fc29fb1 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 13 Jun 2016 09:11:37 +0200 Subject: Get folder moves to work, and fix the mime message moving. --- common/domain/applicationdomaintype.cpp | 2 ++ common/entityreader.cpp | 5 ++++- common/pipeline.cpp | 11 +++++++---- common/synchronizer.cpp | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index d9b0c92..4db2e3b 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -120,6 +120,8 @@ void ApplicationDomainType::setBlobProperty(const QByteArray &key, const QByteAr return; } file.write(value); + //Ensure that the file is written to disk immediately + file.close(); setProperty(key, path); } diff --git a/common/entityreader.cpp b/common/entityreader.cpp index b29b2a3..a3ca8e2 100644 --- a/common/entityreader.cpp +++ b/common/entityreader.cpp @@ -85,7 +85,9 @@ EntityReader::EntityReader(const QByteArray &resourceType, const QBy mDomainTypeAdaptorFactoryPtr(Sink::AdaptorFactoryRegistry::instance().getFactory(resourceType)), mDomainTypeAdaptorFactory(*mDomainTypeAdaptorFactoryPtr) { - + Q_ASSERT(!resourceType.isEmpty()); + Trace() << "resourceType " << resourceType; + Q_ASSERT(mDomainTypeAdaptorFactoryPtr); } template @@ -159,6 +161,7 @@ void EntityReader::readEntity(const Sink::Storage::NamedDatabase &db const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; auto adaptor = mDomainTypeAdaptorFactory.createAdaptor(entity); + Q_ASSERT(adaptor); resultCallback(DomainType::Ptr::create(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, adaptor), operation); return false; }, diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 2c08aa0..5d8a34c 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -221,8 +221,6 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) Trace() << "Pipeline: Modified Entity"; d->transactionItemCount++; - const qint64 newRevision = Storage::maxRevision(d->transaction) + 1; - { flatbuffers::Verifier verifyer(reinterpret_cast(command), size); if (!Commands::VerifyModifyEntityBuffer(verifyer)) { @@ -305,13 +303,18 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) } for (auto processor : d->processors[bufferType]) { - processor->modifiedEntity(key, newRevision, *current, *newAdaptor, d->transaction); + processor->resourceType = d->resourceType; + processor->pipeline = this; + processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); } + //The maxRevision may have changed meanwhile if the entity created sub-entities + const qint64 newRevision = Storage::maxRevision(d->transaction) + 1; // Add metadata buffer flatbuffers::FlatBufferBuilder metadataFbb; { - auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset); + //We add availableProperties to account for the properties that have been changed by the preprocessors + auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset + newAdaptor->availableProperties()); auto metadataBuilder = MetadataBuilder(metadataFbb); metadataBuilder.add_revision(newRevision); metadataBuilder.add_operation(Operation_Modification); diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index b127ec5..46712b5 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -139,6 +139,7 @@ void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray const auto sinkId = syncStore().resolveRemoteId(bufferType, remoteId); const auto found = mainDatabase.contains(sinkId); auto adaptorFactory = Sink::AdaptorFactoryRegistry::instance().getFactory(mResourceType, bufferType); + Q_ASSERT(adaptorFactory); if (!found) { Trace() << "Found a new entity: " << remoteId; createEntity( @@ -178,7 +179,7 @@ void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray Sink::Query query; query.propertyFilter = mergeCriteria; bool merge = false; - Sink::EntityReader reader(mResourceInstanceIdentifier, mResourceType, transaction()); + Sink::EntityReader reader(mResourceType, mResourceInstanceIdentifier, transaction()); reader.query(query, [this, bufferType, remoteId, &merge](const DomainType &o) -> bool{ merge = true; -- cgit v1.2.3