diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-03 09:38:03 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-03 09:38:03 +0200 |
commit | f5b254c87a993988c9cb1fd06b5635f1a6b20f9f (patch) | |
tree | c88a14c151bba5f733b21889944867f14a92f0c7 /common/changereplay.cpp | |
parent | fb5b40088817d420532f7330864e0570278f112e (diff) | |
download | sink-f5b254c87a993988c9cb1fd06b5635f1a6b20f9f.tar.gz sink-f5b254c87a993988c9cb1fd06b5635f1a6b20f9f.zip |
Deal with errors in the change-replay job.
Diffstat (limited to 'common/changereplay.cpp')
-rw-r--r-- | common/changereplay.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/common/changereplay.cpp b/common/changereplay.cpp index aebfdb0..688f47b 100644 --- a/common/changereplay.cpp +++ b/common/changereplay.cpp | |||
@@ -76,6 +76,14 @@ KAsync::Job<void> ChangeReplay::replayNextRevision() | |||
76 | [](const Storage::Error &) {}); | 76 | [](const Storage::Error &) {}); |
77 | const qint64 topRevision = Storage::maxRevision(mainStoreTransaction); | 77 | const qint64 topRevision = Storage::maxRevision(mainStoreTransaction); |
78 | 78 | ||
79 | auto recordReplayedRevision = [this](qint64 revision) { | ||
80 | auto replayStoreTransaction = mChangeReplayStore.createTransaction(Storage::ReadWrite, [](const Sink::Storage::Error &error) { | ||
81 | Warning() << error.message; | ||
82 | }); | ||
83 | replayStoreTransaction.openDatabase().write("lastReplayedRevision", QByteArray::number(revision)); | ||
84 | replayStoreTransaction.commit(); | ||
85 | }; | ||
86 | |||
79 | if (lastReplayedRevision < topRevision) { | 87 | if (lastReplayedRevision < topRevision) { |
80 | Trace() << "Changereplay from " << lastReplayedRevision << " to " << topRevision; | 88 | Trace() << "Changereplay from " << lastReplayedRevision << " to " << topRevision; |
81 | qint64 revision = lastReplayedRevision + 1; | 89 | qint64 revision = lastReplayedRevision + 1; |
@@ -92,14 +100,15 @@ KAsync::Job<void> ChangeReplay::replayNextRevision() | |||
92 | return false; | 100 | return false; |
93 | }, | 101 | }, |
94 | [key](const Storage::Error &) { ErrorMsg() << "Failed to replay change " << key; }); | 102 | [key](const Storage::Error &) { ErrorMsg() << "Failed to replay change " << key; }); |
95 | return replayJob.then<void>([this, revision]() { | 103 | return replayJob.then<void>([this, revision, recordReplayedRevision]() { |
96 | auto replayStoreTransaction = mChangeReplayStore.createTransaction(Storage::ReadWrite, [](const Sink::Storage::Error &error) { | ||
97 | Warning() << error.message; | ||
98 | }); | ||
99 | replayStoreTransaction.openDatabase().write("lastReplayedRevision", QByteArray::number(revision)); | ||
100 | replayStoreTransaction.commit(); | ||
101 | Trace() << "Replayed until " << revision; | 104 | Trace() << "Replayed until " << revision; |
102 | }).then<void>([this]() { | 105 | recordReplayedRevision(revision); |
106 | //replay until we're done | ||
107 | replayNextRevision().exec(); | ||
108 | }, | ||
109 | [this, revision, recordReplayedRevision](int, QString) { | ||
110 | Trace() << "Change replay failed" << revision; | ||
111 | recordReplayedRevision(revision); | ||
103 | //replay until we're done | 112 | //replay until we're done |
104 | replayNextRevision().exec(); | 113 | replayNextRevision().exec(); |
105 | }); | 114 | }); |