File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -100,9 +100,25 @@ export default class NoteSplitterPlugin extends Plugin {
100100 }
101101
102102 const filePath = normalizePath ( `${ groupFolderPath } /${ fileName } .md` ) ;
103- await this . app . vault . create (
104- filePath , line
105- ) ;
103+
104+ try {
105+ await this . app . vault . create (
106+ filePath , line
107+ ) ;
108+ } catch ( err ) {
109+ if ( err . message . includes ( "already exists" ) ) {
110+ const newFilePath = `${ groupFolderPath } /Tab conflict ${ crypto . randomUUID ( ) } .md` ;
111+ try {
112+ await this . app . vault . create (
113+ newFilePath , line
114+ ) ;
115+ } catch ( err ) {
116+ console . error ( err ) ;
117+ new Notice ( `Error creating file: ${ err . message } ` ) ;
118+ }
119+ }
120+ throw err ;
121+ }
106122 }
107123 new Notice ( "Split into " + splitLines . length + " note" + ( splitLines . length > 1 ? "s" : "" ) ) ;
108124 } ,
You can’t perform that action at this time.
0 commit comments