fix: short-circuit draft folder creation when it already exists

This commit is contained in:
mssoftjp 2025-12-14 12:41:16 +09:00
parent 2f77ca92dc
commit ab368ee387

View file

@ -30,16 +30,15 @@ export class DraftManager {
const folderPath = this.getDraftFolderPath(app);
const abstractFile = app.vault.getAbstractFileByPath(folderPath);
if (abstractFile instanceof TFolder) {
return;
}
if (abstractFile) {
this.logger?.warn('Draft path exists but is not a folder', { folderPath });
return;
}
try {
if (abstractFile instanceof TFolder) {
return; // already exists and is a folder
}
if (abstractFile) {
this.logger?.warn('Draft path exists but is not a folder', { folderPath });
return;
}
await app.vault.createFolder(folderPath);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);