diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-30 09:32:52 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-30 09:32:52 +0100 |
commit | 02c311e38b8b9b80814a4e8e582d5c5a56a51056 (patch) | |
tree | 914255d577be2f17501c546e6d08b80aa23ca165 /examples/maildirresource/maildirresource.cpp | |
parent | e99453c21eb9100d6fe05ccec153fe6e640bb440 (diff) | |
download | sink-02c311e38b8b9b80814a4e8e582d5c5a56a51056.tar.gz sink-02c311e38b8b9b80814a4e8e582d5c5a56a51056.zip |
Don't expose enabling/disabling of changerecording to resource
implementations
Diffstat (limited to 'examples/maildirresource/maildirresource.cpp')
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 45ee8c1..6c6c5aa 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -344,28 +344,24 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | KAsync::Job<void> MaildirResource::synchronizeWithSource() | 347 | KAsync::Job<void> MaildirResource::synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) |
348 | { | 348 | { |
349 | Log() << " Synchronizing"; | 349 | Log() << " Synchronizing"; |
350 | return KAsync::start<void>([this]() { | 350 | return KAsync::start<void>([this, &mainStore, &synchronizationStore]() { |
351 | //Changereplay would deadlock otherwise when trying to open the synchronization store | 351 | auto transaction = mainStore.createTransaction(Akonadi2::Storage::ReadOnly); |
352 | enableChangeReplay(false); | ||
353 | auto transaction = Akonadi2::Storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier, Akonadi2::Storage::ReadOnly).createTransaction(Akonadi2::Storage::ReadOnly); | ||
354 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); | ||
355 | { | 352 | { |
356 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 353 | auto synchronizationTransaction = synchronizationStore.createTransaction(Akonadi2::Storage::ReadWrite); |
357 | synchronizeFolders(transaction, synchronizationTransaction); | 354 | synchronizeFolders(transaction, synchronizationTransaction); |
358 | //The next sync needs the folders available | 355 | //The next sync needs the folders available |
359 | synchronizationTransaction.commit(); | 356 | synchronizationTransaction.commit(); |
360 | } | 357 | } |
361 | for (const auto &folder : listAvailableFolders()) { | 358 | for (const auto &folder : listAvailableFolders()) { |
362 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 359 | auto synchronizationTransaction = synchronizationStore.createTransaction(Akonadi2::Storage::ReadWrite); |
363 | synchronizeMails(transaction, synchronizationTransaction, folder); | 360 | synchronizeMails(transaction, synchronizationTransaction, folder); |
364 | //Don't let the transaction grow too much | 361 | //Don't let the transaction grow too much |
365 | synchronizationTransaction.commit(); | 362 | synchronizationTransaction.commit(); |
366 | } | 363 | } |
367 | Log() << "Done Synchronizing"; | 364 | Log() << "Done Synchronizing"; |
368 | enableChangeReplay(true); | ||
369 | }); | 365 | }); |
370 | } | 366 | } |
371 | 367 | ||