Reinstated check if file already exists
Plugin will no longer download a poster if it already exists, to avoid unnecessary downloads and in case the user has modified the saved image themselves
This commit is contained in:
parent
62e0f20634
commit
970432dcfb
2 changed files with 6 additions and 3 deletions
|
|
@ -327,9 +327,11 @@ export default class MediaDbPlugin extends Plugin {
|
|||
await this.app.vault.createFolder(this.settings.imageFolder);
|
||||
}
|
||||
|
||||
const response = await requestUrl({ url: imageurl, method: 'GET' });
|
||||
await this.app.vault.createBinary(imagepath, response.arrayBuffer);
|
||||
|
||||
if (!this.app.vault.getAbstractFileByPath(imagepath)) {
|
||||
const response = await requestUrl({ url: imageurl, method: 'GET' });
|
||||
await this.app.vault.createBinary(imagepath, response.arrayBuffer);
|
||||
}
|
||||
|
||||
// Update model to use local image path
|
||||
mediaTypeModel.image = `[[${imagepath}]]`;
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue