1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Fix database upgrade

This commit is contained in:
Laurent Cozic
2018-03-16 14:32:47 +00:00
parent 86a0e34975
commit ae9ecdad40
8 changed files with 43 additions and 26 deletions

View File

@ -4,6 +4,7 @@ const Note = require('lib/models/Note');
const Resource = require('lib/models/Resource');
const BaseModel = require('lib/BaseModel');
const BaseService = require('lib/services/BaseService');
const { shim } = require('lib/shim');
class ResourceService extends BaseService {
@ -23,7 +24,7 @@ class ResourceService extends BaseService {
WHERE item_type = ?
AND id > ?
ORDER BY id ASC
LIMIT 10
LIMIT 100
`, [BaseModel.TYPE_NOTE, lastId]);
if (!changes.length) break;
@ -77,6 +78,21 @@ class ResourceService extends BaseService {
await this.deleteOrphanResources();
}
static runInBackground() {
if (this.isRunningInBackground_) return;
this.isRunningInBackground_ = true;
const service = new ResourceService();
setTimeout(() => {
service.maintenance();
}, 1000 * 30);
shim.setInterval(() => {
service.maintenance();
}, 1000 * 60 * 60 * 4);
}
}
module.exports = ResourceService;