Skip to content

Commit 970432d

Browse files
committed
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
1 parent 62e0f20 commit 970432d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Available variables that can be used in template tags are the same variables fro
3737
I also published my own templates [here](https://github.com/mProjectsCode/obsidian-media-db-templates).
3838
3939
#### Download poster images
40+
4041
Allows you to automatically download the poster images for a new media, ensuring offline access. The images are saved as `type_title (year)` e.g. `movie_The Perfect Storm (2000)` with a user chosen save location.
4142
4243
#### Metadata field customization

src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,11 @@ export default class MediaDbPlugin extends Plugin {
327327
await this.app.vault.createFolder(this.settings.imageFolder);
328328
}
329329

330-
const response = await requestUrl({ url: imageurl, method: 'GET' });
331-
await this.app.vault.createBinary(imagepath, response.arrayBuffer);
332-
330+
if (!this.app.vault.getAbstractFileByPath(imagepath)) {
331+
const response = await requestUrl({ url: imageurl, method: 'GET' });
332+
await this.app.vault.createBinary(imagepath, response.arrayBuffer);
333+
}
334+
333335
// Update model to use local image path
334336
mediaTypeModel.image = `[[${imagepath}]]`;
335337
} catch (e) {

0 commit comments

Comments
 (0)