mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 02:03:07 +08:00
Cleanup syncback task
This commit is contained in:
parent
c7422ffaea
commit
11a3a8f58e
1 changed files with 14 additions and 2 deletions
|
@ -40,7 +40,7 @@ class SyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessage(msg) {
|
_onMessage(msg) {
|
||||||
const {type, data} = JSON.parse(msg)
|
const {type} = JSON.parse(msg)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MessageTypes.ACCOUNT_UPDATED:
|
case MessageTypes.ACCOUNT_UPDATED:
|
||||||
this._onAccountUpdated(); break;
|
this._onAccountUpdated(); break;
|
||||||
|
@ -127,7 +127,19 @@ class SyncWorker {
|
||||||
const where = {where: {status: "NEW"}, limit: 100};
|
const where = {where: {status: "NEW"}, limit: 100};
|
||||||
return this._db.SyncbackRequest.findAll(where)
|
return this._db.SyncbackRequest.findAll(where)
|
||||||
.map((req) => SyncbackTaskFactory.create(this._account, req))
|
.map((req) => SyncbackTaskFactory.create(this._account, req))
|
||||||
.each(this._conn.runOperation)
|
.each(this.runSyncbackTask.bind(this))
|
||||||
|
}
|
||||||
|
|
||||||
|
runSyncbackTask(task) {
|
||||||
|
return this._conn.runOperation(task)
|
||||||
|
.then(() => {
|
||||||
|
task.syncbackRequest.status = "SUCCEEDED"
|
||||||
|
}).catch((error) => {
|
||||||
|
task.syncbackRequest.error = error
|
||||||
|
task.syncbackRequest.status = "FAILED"
|
||||||
|
}).finally(() => {
|
||||||
|
return task.syncbackRequest.save()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
syncAllCategories() {
|
syncAllCategories() {
|
||||||
|
|
Loading…
Reference in a new issue