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

Improved logic to set resource file size

This commit is contained in:
Laurent Cozic
2019-05-12 15:53:42 +01:00
parent e57bfad9b1
commit 3e808f05fd
6 changed files with 61 additions and 6 deletions

View File

@@ -111,6 +111,20 @@ class ResourceService extends BaseService {
}
}
static async autoSetFileSize(resourceId, filePath) {
const itDoes = await shim.fsDriver().waitTillExists(filePath);
const fileStat = await shim.fsDriver().stat(filePath);
await Resource.setFileSizeOnly(resourceId, fileStat.size);
}
static async autoSetFileSizes() {
const resources = await Resource.needFileSizeSet();
for (const r of resources) {
await this.autoSetFileSize(r.id, Resource.fullPath(r));
}
}
async maintenance() {
await this.indexNoteResources();
await this.deleteOrphanResources();