diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-13 09:11:37 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-13 09:11:37 +0200 |
commit | 1e2e4437094d80f1cdd849c7341019910fc29fb1 (patch) | |
tree | 5f75e3dab8da864eab8a51c06be205a24e185dcb /common | |
parent | 3fa1766af3fa85067d4b2d48c8410e6c201ae323 (diff) | |
download | sink-1e2e4437094d80f1cdd849c7341019910fc29fb1.tar.gz sink-1e2e4437094d80f1cdd849c7341019910fc29fb1.zip |
Get folder moves to work, and fix the mime message moving.
Diffstat (limited to 'common')
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 2 | ||||
-rw-r--r-- | common/entityreader.cpp | 5 | ||||
-rw-r--r-- | common/pipeline.cpp | 11 | ||||
-rw-r--r-- | common/synchronizer.cpp | 3 |
4 files changed, 15 insertions, 6 deletions
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 | |||
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | file.write(value); | 122 | file.write(value); |
123 | //Ensure that the file is written to disk immediately | ||
124 | file.close(); | ||
123 | setProperty(key, path); | 125 | setProperty(key, path); |
124 | } | 126 | } |
125 | 127 | ||
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<DomainType>::EntityReader(const QByteArray &resourceType, const QBy | |||
85 | mDomainTypeAdaptorFactoryPtr(Sink::AdaptorFactoryRegistry::instance().getFactory<DomainType>(resourceType)), | 85 | mDomainTypeAdaptorFactoryPtr(Sink::AdaptorFactoryRegistry::instance().getFactory<DomainType>(resourceType)), |
86 | mDomainTypeAdaptorFactory(*mDomainTypeAdaptorFactoryPtr) | 86 | mDomainTypeAdaptorFactory(*mDomainTypeAdaptorFactoryPtr) |
87 | { | 87 | { |
88 | 88 | Q_ASSERT(!resourceType.isEmpty()); | |
89 | Trace() << "resourceType " << resourceType; | ||
90 | Q_ASSERT(mDomainTypeAdaptorFactoryPtr); | ||
89 | } | 91 | } |
90 | 92 | ||
91 | template <class DomainType> | 93 | template <class DomainType> |
@@ -159,6 +161,7 @@ void EntityReader<DomainType>::readEntity(const Sink::Storage::NamedDatabase &db | |||
159 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | 161 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; |
160 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; | 162 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; |
161 | auto adaptor = mDomainTypeAdaptorFactory.createAdaptor(entity); | 163 | auto adaptor = mDomainTypeAdaptorFactory.createAdaptor(entity); |
164 | Q_ASSERT(adaptor); | ||
162 | resultCallback(DomainType::Ptr::create(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, adaptor), operation); | 165 | resultCallback(DomainType::Ptr::create(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, adaptor), operation); |
163 | return false; | 166 | return false; |
164 | }, | 167 | }, |
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<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
221 | Trace() << "Pipeline: Modified Entity"; | 221 | Trace() << "Pipeline: Modified Entity"; |
222 | d->transactionItemCount++; | 222 | d->transactionItemCount++; |
223 | 223 | ||
224 | const qint64 newRevision = Storage::maxRevision(d->transaction) + 1; | ||
225 | |||
226 | { | 224 | { |
227 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); | 225 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); |
228 | if (!Commands::VerifyModifyEntityBuffer(verifyer)) { | 226 | if (!Commands::VerifyModifyEntityBuffer(verifyer)) { |
@@ -305,13 +303,18 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
305 | } | 303 | } |
306 | 304 | ||
307 | for (auto processor : d->processors[bufferType]) { | 305 | for (auto processor : d->processors[bufferType]) { |
308 | processor->modifiedEntity(key, newRevision, *current, *newAdaptor, d->transaction); | 306 | processor->resourceType = d->resourceType; |
307 | processor->pipeline = this; | ||
308 | processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); | ||
309 | } | 309 | } |
310 | //The maxRevision may have changed meanwhile if the entity created sub-entities | ||
311 | const qint64 newRevision = Storage::maxRevision(d->transaction) + 1; | ||
310 | 312 | ||
311 | // Add metadata buffer | 313 | // Add metadata buffer |
312 | flatbuffers::FlatBufferBuilder metadataFbb; | 314 | flatbuffers::FlatBufferBuilder metadataFbb; |
313 | { | 315 | { |
314 | auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset); | 316 | //We add availableProperties to account for the properties that have been changed by the preprocessors |
317 | auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset + newAdaptor->availableProperties()); | ||
315 | auto metadataBuilder = MetadataBuilder(metadataFbb); | 318 | auto metadataBuilder = MetadataBuilder(metadataFbb); |
316 | metadataBuilder.add_revision(newRevision); | 319 | metadataBuilder.add_revision(newRevision); |
317 | metadataBuilder.add_operation(Operation_Modification); | 320 | 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 | |||
139 | const auto sinkId = syncStore().resolveRemoteId(bufferType, remoteId); | 139 | const auto sinkId = syncStore().resolveRemoteId(bufferType, remoteId); |
140 | const auto found = mainDatabase.contains(sinkId); | 140 | const auto found = mainDatabase.contains(sinkId); |
141 | auto adaptorFactory = Sink::AdaptorFactoryRegistry::instance().getFactory(mResourceType, bufferType); | 141 | auto adaptorFactory = Sink::AdaptorFactoryRegistry::instance().getFactory(mResourceType, bufferType); |
142 | Q_ASSERT(adaptorFactory); | ||
142 | if (!found) { | 143 | if (!found) { |
143 | Trace() << "Found a new entity: " << remoteId; | 144 | Trace() << "Found a new entity: " << remoteId; |
144 | createEntity( | 145 | createEntity( |
@@ -178,7 +179,7 @@ void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray | |||
178 | Sink::Query query; | 179 | Sink::Query query; |
179 | query.propertyFilter = mergeCriteria; | 180 | query.propertyFilter = mergeCriteria; |
180 | bool merge = false; | 181 | bool merge = false; |
181 | Sink::EntityReader<DomainType> reader(mResourceInstanceIdentifier, mResourceType, transaction()); | 182 | Sink::EntityReader<DomainType> reader(mResourceType, mResourceInstanceIdentifier, transaction()); |
182 | reader.query(query, | 183 | reader.query(query, |
183 | [this, bufferType, remoteId, &merge](const DomainType &o) -> bool{ | 184 | [this, bufferType, remoteId, &merge](const DomainType &o) -> bool{ |
184 | merge = true; | 185 | merge = true; |