Skip to content

Commit 9514627

Browse files
committed
Fixed EEXISTS error. Reworked transfer messages. Cleanup.
1 parent a2bcfc2 commit 9514627

File tree

3 files changed

+28
-56
lines changed

3 files changed

+28
-56
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ipcMain.handle('save-file', (event, filePath, content) => {
9494

9595
ipcMain.handle('create-folder', (event, filePath) => {
9696
console.log('ipcMain', 'create-folder', filePath)
97-
fs.mkdirSync(filePath)
97+
fs.mkdirSync(filePath, { recursive: true})
9898
return true
9999
})
100100

ui/arduino2/main.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ function App(state, emit) {
2121
emit('load-disk-files')
2222
return html`<div id="app"><p>Loading files...</p></div>`
2323
}
24-
25-
if (state.isRemoving) return html`<div id="app"><p>Removing...</p></div>`
24+
let progressMessage = ''
25+
if (state.transferringProgress != null){
26+
progressMessage = ` [${state.transferringProgress}]`
27+
}
28+
if (state.isRemoving) return html`<div id="app"><p>Removing ${state.currentFSItem}</p></div>`
2629
if (state.isConnecting) return html`<div id="app"><p>Connecting...</p></div>`
2730
if (state.isLoadingFiles) return html`<div id="app"><p>Loading files...</p></div>`
28-
if (state.isSaving) return html`<div id="app"><p>Saving file... ${state.savingProgress}</p></div>`
29-
if (state.isTransferring) return html`<div id="app"><p>Transferring file: ${state.transferringProgress}</p></div>`
31+
if (state.isSaving) return html`<div id="app"><p>Saving ${state.currentFSItem}${progressMessage}</p></div>`
32+
if (state.isTransferring) return html`<div id="app"><p>Transferring ${state.currentFSItem}${progressMessage}</p></div>`
3033

3134
return state.view == 'editor' ? EditorView(state, emit) : FileManagerView(state, emit)
3235
}

ui/arduino2/store.js

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ async function store(state, emitter) {
101101
state.isTransferring = false
102102
state.transferringProgress = 0
103103
state.isRemoving = false
104+
state.currentFSItem = null
104105

105106
state.isLoadingFiles = false
106107
state.dialogs = []
@@ -269,6 +270,7 @@ async function store(state, emitter) {
269270

270271
const save = async () => {
271272
state.isSaving = true
273+
state.currentFSItem = openFile.fileName
272274
emitter.emit('render')
273275
try {
274276
if (openFile.source == 'board') {
@@ -439,6 +441,8 @@ async function store(state, emitter) {
439441
if (confirmBoardDeletion) {
440442
for (let i in state.selectedBoardFiles) {
441443
const file = state.selectedBoardFiles[i]
444+
state.currentFSItem = file.fileName
445+
emitter.emit('render')
442446
if (file.type === 'folder') {
443447
const folder_path = serial.getFullPath('/', state.boardNavigationPath, file.fileName)
444448
let command = microPythonFShelpers
@@ -485,46 +489,6 @@ async function store(state, emitter) {
485489
}
486490
}
487491
}
488-
// for (let i in state.selectedFiles) {
489-
// const file = state.selectedFiles[i]
490-
491-
// if (file.source === 'board') {
492-
// if (file.type === 'folder') {
493-
// let folder_path = serial.getFullPath('/', state.boardNavigationPath, file.fileName)
494-
// let command = microPythonFShelpers
495-
// command += microPythonDeleteFolder
496-
// command += `delete_folder('${folder_path}')`
497-
// await serial.run(command)
498-
// } else {
499-
// await serial.removeFile(
500-
// serial.getFullPath(
501-
// '/',
502-
// state.boardNavigationPath,
503-
// file.fileName
504-
// )
505-
// )
506-
// }
507-
// } else {
508-
// if (file.type === 'folder') {
509-
// await disk.removeFolder(
510-
// disk.getFullPath(
511-
// state.diskNavigationRoot,
512-
// state.diskNavigationPath,
513-
// file.fileName
514-
// )
515-
// )
516-
// } else {
517-
// await disk.removeFile(
518-
// disk.getFullPath(
519-
// state.diskNavigationRoot,
520-
// state.diskNavigationPath,
521-
// file.fileName
522-
// )
523-
// )
524-
// }
525-
// }
526-
// }
527-
528492
emitter.emit('refresh-files')
529493
// state.selectedFiles = []
530494
state.isRemoving = false
@@ -593,11 +557,11 @@ async function store(state, emitter) {
593557
newFileContent
594558
)
595559
}
596-
state.creatingFile = null
597-
state.creatingFolder = null
560+
598561

599562
setTimeout(() => {
600563
state.creatingFile = null
564+
state.creatingFolder = null
601565
emitter.emit('refresh-files')
602566
emitter.emit('render')
603567
}, 200)
@@ -714,11 +678,12 @@ async function store(state, emitter) {
714678
emitter.emit('render')
715679
for (let i in state.selectedDiskFiles) {
716680
const file = state.selectedDiskFiles[i]
681+
state.currentFSItem = file.fileName
682+
state.transferringProgress = null
717683
if (file.type === 'folder') {
718684
const confirmAction = alert(`Folder transfer not yet available`)
719685
continue
720686
}
721-
722687
await serial.uploadFile(
723688
disk.getFullPath(
724689
state.diskNavigationRoot,
@@ -750,10 +715,11 @@ async function store(state, emitter) {
750715
const confirmAction = confirm(`Copying these items might overwrite existing files/folders on your computer:\n ${fileNames.join('\n')}`, 'Cancel', 'Proceed')
751716
if (confirmAction) {
752717
state.isTransferring = true
753-
emitter.emit('render')
754718
for (let i in state.selectedBoardFiles) {
755719
const file = state.selectedBoardFiles[i]
756720
if (file.type === 'folder') {
721+
state.currentFSItem = file.fileName
722+
emitter.emit('render')
757723
const folder_path = serial.getFullPath('/', state.boardNavigationPath, file.fileName)
758724
let command = microPythonFShelpers
759725
command += microPythonFileTree
@@ -769,22 +735,29 @@ async function store(state, emitter) {
769735
const sourceRelativePath = sourcePath.split(state.boardNavigationPath)[1]
770736
if(type === 'folder'){
771737
const newFolderPath = disk.getFullPath(state.diskNavigationRoot, state.diskNavigationPath,`/${sourceRelativePath}`)
738+
state.currentFSItem = file.fileName
739+
state.transferringProgress = null
740+
emitter.emit('render')
772741
await disk.createFolder(newFolderPath)
773742
}else{
774743
const fileDestinationPath = disk.getFullPath(state.diskNavigationRoot, state.diskNavigationPath,`/${sourceRelativePath}`)
775-
state.transferringProgress = sourcePath
744+
state.currentFSItem = file.fileName
745+
state.transferringProgress = null
746+
emitter.emit('render')
776747
await serial.downloadFile(
777748
sourcePath,
778749
fileDestinationPath,
779750
(e) => {
780751
state.transferringProgress = e
781752
emitter.emit('render')
782753
})
783-
emitter.emit('render')
784754
}
785755
}
786756
continue
787757
}
758+
state.currentFSItem = file.fileName
759+
state.transferringProgress = null
760+
emitter.emit('render')
788761
await serial.downloadFile(
789762
serial.getFullPath(
790763
'/',
@@ -795,11 +768,7 @@ async function store(state, emitter) {
795768
state.diskNavigationRoot,
796769
state.diskNavigationPath,
797770
file.fileName
798-
),
799-
(e) => {
800-
state.transferringProgress = e
801-
emitter.emit('render')
802-
}
771+
)
803772
)
804773
}
805774
state.isTransferring = false

0 commit comments

Comments
 (0)