From 8dec30fae3d62428d176a524b9f2e4d91fe14b8c Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Wed, 27 Sep 2023 22:12:34 +0800 Subject: [PATCH] fix: file already exists error caused by having duplicate article titles --- src/main.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index c01dd3e..8ea0d2d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -363,7 +363,17 @@ export default class OmnivorePlugin extends Plugin { continue; } // file doesn't exist, so we need to create it - await this.app.vault.create(normalizedPath, content); + try { + await this.app.vault.create(normalizedPath, content); + } catch (error) { + if (error.toString().includes("File already exists")) { + new Notice( + `Skipping file creation: ${normalizedPath}. Please check if you have duplicated article titles and delete the file if needed.` + ); + } else { + throw error; + } + } } }