1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

All: Optimised resource download queue by exiting early if resources are already downloaded

This commit is contained in:
Laurent Cozic
2019-06-15 21:48:37 +01:00
parent 0200aa92de
commit 349cade946
2 changed files with 15 additions and 2 deletions

View File

@@ -32,6 +32,11 @@ class Resource extends BaseItem {
return imageMimeTypes.indexOf(type.toLowerCase()) >= 0;
}
static fetchStatuses(resourceIds) {
if (!resourceIds.length) return [];
return this.db().selectAll('SELECT resource_id, fetch_status FROM resource_local_states WHERE resource_id IN ("' + resourceIds.join('","') + '")');
}
static needToBeFetched(resourceDownloadMode = null, limit = null) {
let sql = ['SELECT * FROM resources WHERE encryption_applied = 0 AND id IN (SELECT resource_id FROM resource_local_states WHERE fetch_status = ?)'];
if (resourceDownloadMode !== 'always') {