@@ -623,29 +623,41 @@ class FileDialog extends GenericModal {
623623 async _handleMoveButton ( ) {
624624 // Get the new path
625625 const newFolderDialog = new FileDialog ( "folder-select" , this . _showBusy ) ;
626- let hidePaths = new Set ( ) ;
627- hidePaths . add ( this . _getSelectedFilePath ( ) ) ;
626+ const hidePaths = new Set ( this . _getSelectedFilePath ( ) ) ;
628627 hidePaths . add ( this . _currentPath ) ;
629628 let newFolder = await newFolderDialog . open ( this . _fileHelper , FILE_DIALOG_MOVE , hidePaths , false ) ;
630629 let errors = false ;
630+ let movedAny = false ;
631631 if ( newFolder ) {
632632 const files = this . _getSelectedFilesInfo ( ) ;
633633 for ( let file of files ) {
634634 const filename = file . filename ;
635635 const filetype = file . filetype == "folder" ? "folder" : "file" ;
636636 const oldPath = this . _currentPath + filename ;
637637 const newPath = newFolder + filename ;
638- if ( await this . _showBusy ( this . _fileHelper . fileExists ( newPath ) ) ) {
639- this . _showMessage ( `Error moving ${ oldPath } . Another ${ filetype } with the same name already exists at ${ newPath } .` ) ;
640- errors = true ;
641- } else if ( ! ( await this . _showBusy ( this . _fileHelper . move ( oldPath , newPath ) ) ) ) {
642- this . _showMessage ( `Error moving ${ oldPath } to ${ newPath } . Make sure the file you are moving exists.` ) ;
638+ let errorMessage ;
639+ try {
640+ if ( await this . _showBusy ( this . _fileHelper . fileExists ( newPath ) ) ) {
641+ errorMessage = `Error moving ${ oldPath } . Another ${ filetype } with the same name already exists at ${ newPath } .` ;
642+ } else if ( await this . _showBusy ( this . _fileHelper . move ( oldPath , newPath ) ) ) {
643+ movedAny = true ;
644+ } else {
645+ errorMessage = `Error moving ${ oldPath } to ${ newPath } . Make sure the file you are moving exists.` ;
646+ }
647+ } catch ( error ) {
648+ errorMessage = `Error moving ${ oldPath } to ${ newPath } : ${ error ?. message ?? String ( error ) } ` ;
649+ }
650+ if ( errorMessage ) {
643651 errors = true ;
652+ await this . _showMessage ( errorMessage , { plainText : true } ) ;
644653 }
645654 }
646655 if ( ! errors ) {
647656 // Go to the new location
648657 await this . _openFolder ( newFolder ) ;
658+ } else if ( movedAny ) {
659+ // Update the source list after a partially successful move
660+ await this . _openFolder ( ) ;
649661 }
650662 }
651663 }
@@ -773,7 +785,7 @@ class FileDialog extends GenericModal {
773785 paths . push ( this . _currentPath ) ;
774786 }
775787 } else {
776- paths . push ( this . _currentPath + filename ) ;
788+ paths . push ( this . _currentPath + file . filename ) ;
777789 }
778790 }
779791
0 commit comments