@@ -225,23 +225,25 @@ class FileManager extends Plugin {
225225 * @param {string } folderPath base folder path
226226 * @returns {void }
227227 */
228- async writeMultipleFiles ( filePaths , fileData , folderPath ) {
228+ async writeMultipleFiles ( filePaths : string [ ] , fileData : string [ ] , folderPath : string ) {
229+ if ( this . currentRequest ) {
230+ const canCall = await this . askUserPermission ( `writeFile` , `will write multiple files to ${ folderPath } ...` )
231+ const required = this . appManager . isRequired ( this . currentRequest . from )
232+ if ( canCall && ! required ) {
233+ this . call ( 'notification' , 'toast' , fileChangedToastMsg ( this . currentRequest . from , folderPath ) )
234+ }
235+ }
229236 try {
230- let alert = true
231237 for ( let i = 0 ; i < filePaths . length ; i ++ ) {
232238 const installPath = folderPath + "/" + filePaths [ i ]
233239
234240 let path = this . normalize ( installPath )
235241 path = this . limitPluginScope ( path )
236242
237- if ( await this . exists ( path ) ) {
238- await this . _handleIsFile ( path , `Cannot write file ${ path } ` )
239- await this . setMultipleFileContent ( path , fileData [ i ] , folderPath , alert )
240- } else {
241- await this . setMultipleFileContent ( path , fileData [ i ] , folderPath , alert )
243+ if ( ! await this . exists ( path ) ) {
244+ await this . _setFileInternal ( path , fileData [ i ] )
242245 this . emit ( 'fileAdded' , path )
243246 }
244- alert = false
245247 }
246248 } catch ( e ) {
247249 throw new Error ( e )
@@ -603,18 +605,6 @@ class FileManager extends Plugin {
603605 return await this . _setFileInternal ( path , content )
604606 }
605607
606- async setMultipleFileContent ( path , content , folderPath , alert ) {
607- if ( this . currentRequest ) {
608- const canCall = await this . askUserPermission ( `writeFile` , `modifying ${ folderPath } ...` )
609- const required = this . appManager . isRequired ( this . currentRequest . from )
610- if ( canCall && ! required && alert ) {
611- // inform the user about modification after permission is granted and even if permission was saved before
612- this . call ( 'notification' , 'toast' , fileChangedToastMsg ( this . currentRequest . from , folderPath ) )
613- }
614- }
615- return await this . _setFileInternal ( path , content )
616- }
617-
618608 _setFileInternal ( path , content ) {
619609 const provider = this . fileProviderOf ( path )
620610 if ( ! provider ) throw createError ( { code : 'ENOENT' , message : `${ path } not available` } )
0 commit comments