1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

All: Allow deleting and syncing deleted resources

This commit is contained in:
Laurent Cozic
2018-03-15 17:46:54 +00:00
parent df7b981e5e
commit 945018b698
5 changed files with 56 additions and 6 deletions

View File

@@ -436,8 +436,8 @@ class Note extends BaseItem {
// });
// }
static batchDelete(ids, options = null) {
const result = super.batchDelete(ids, options);
static async batchDelete(ids, options = null) {
const result = await super.batchDelete(ids, options);
for (let i = 0; i < ids.length; i++) {
ItemChange.add(BaseModel.TYPE_NOTE, ids[i], ItemChange.TYPE_DELETE);

View File

@@ -143,6 +143,19 @@ class Resource extends BaseItem {
return url.substr(2);
}
static async batchDelete(ids, options = null) {
// For resources, there's not really batch deleting since there's the file data to delete
// too, so each is processed one by one with the item being deleted last (since the db
// call is the less likely to fail).
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
const resource = await Resource.load(id);
const path = Resource.fullPath(resource);
await this.fsDriver().remove(path);
await super.batchDelete([id], options)
}
}
}
Resource.IMAGE_MAX_DIMENSION = 1920;