Skip to content

Commit

Permalink
feat: ignore folder existence error
Browse files Browse the repository at this point in the history
  • Loading branch information
sundevista committed Jul 20, 2024
1 parent 7f78136 commit 221508b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/modals/insert-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ export class InsertTemplateModal extends Modal {
try {
const data = await getVideoData(this.videoUrl, this.plugin.settings);

if (!this.app.vault.getAbstractFileByPath(this.plugin.settings.folder)) {
if (this.plugin.settings.createPaths && !isFolderExists(this.plugin.settings.folder, this.app)) {
if (this.plugin.settings.createPaths && !isFolderExists(this.plugin.settings.folder, this.app)) {
try {
await this.app.vault.createFolder(this.plugin.settings.folder);
} else {
throw new Error(`Folder '${this.plugin.settings.folder}' does not exist`);
} catch (err) {
console.warn('Folder already exists');
}
} else {
throw new Error(`Folder '${this.plugin.settings.folder}' does not exist`);
}

// Create a new file with the title of the video
Expand Down
2 changes: 1 addition & 1 deletion src/utils/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function parseISODuration(data: string): string {
}

export function sanitizeFilename(text: string): string {
return text.replace(/[/:*?"<>|#^[\\\]]/g, '');
return text.replace(/[/:*?"<>#^[\\\]]/g, '');
}

export function filterStringData(text: string): string {
Expand Down

0 comments on commit 221508b

Please sign in to comment.