@@ -752,6 +752,31 @@ async function store(state, emitter) {
752
752
log ( 'upload-files' )
753
753
state . isTransferring = true
754
754
emitter . emit ( 'render' )
755
+
756
+ // Check which files will be overwritten on the board
757
+ const willOverwrite = await checkOverwrite ( {
758
+ source : 'board' ,
759
+ fileNames : state . selectedFiles . map ( f => f . fileName ) ,
760
+ parentPath : serial . getFullPath (
761
+ state . boardNavigationRoot ,
762
+ state . boardNavigationPath ,
763
+ ''
764
+ ) ,
765
+ } )
766
+
767
+ if ( willOverwrite . length > 0 ) {
768
+ let message = `You are about to overwrite the following files/folders on your board:\n\n`
769
+ willOverwrite . forEach ( f => message += `${ f . fileName } \n` )
770
+ message += `\n`
771
+ message += `Are you sure you want to proceed?`
772
+ const confirmAction = confirm ( message , 'Cancel' , 'Yes' )
773
+ if ( ! confirmAction ) {
774
+ state . isTransferring = false
775
+ emitter . emit ( 'render' )
776
+ return
777
+ }
778
+ }
779
+
755
780
for ( let i in state . selectedFiles ) {
756
781
const file = state . selectedFiles [ i ]
757
782
const srcPath = disk . getFullPath (
@@ -793,6 +818,30 @@ async function store(state, emitter) {
793
818
state . isTransferring = true
794
819
emitter . emit ( 'render' )
795
820
821
+ // Check which files will be overwritten on the disk
822
+ const willOverwrite = await checkOverwrite ( {
823
+ source : 'disk' ,
824
+ fileNames : state . selectedFiles . map ( f => f . fileName ) ,
825
+ parentPath : disk . getFullPath (
826
+ state . diskNavigationRoot ,
827
+ state . diskNavigationPath ,
828
+ ''
829
+ ) ,
830
+ } )
831
+
832
+ if ( willOverwrite . length > 0 ) {
833
+ let message = `You are about to overwrite the following files/folders on your disk:\n\n`
834
+ willOverwrite . forEach ( f => message += `${ f . fileName } \n` )
835
+ message += `\n`
836
+ message += `Are you sure you want to proceed?`
837
+ const confirmAction = confirm ( message , 'Cancel' , 'Yes' )
838
+ if ( ! confirmAction ) {
839
+ state . isTransferring = false
840
+ emitter . emit ( 'render' )
841
+ return
842
+ }
843
+ }
844
+
796
845
for ( let i in state . selectedFiles ) {
797
846
const file = state . selectedFiles [ i ]
798
847
const srcPath = serial . getFullPath (
@@ -971,7 +1020,7 @@ async function checkOverwrite({ fileNames = [], parentPath, source }) {
971
1020
let files = [ ]
972
1021
let overwrite = [ ]
973
1022
if ( source === 'board' ) {
974
- files = getBoardFiles ( parentPath )
1023
+ files = await getBoardFiles ( parentPath )
975
1024
} else {
976
1025
files = await getDiskFiles ( parentPath )
977
1026
}
0 commit comments