Skip to content

Commit 043d0b8

Browse files
committed
BugFix: folder transfer from board to disk when not in root.
1 parent 45562de commit 043d0b8

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function traverseDir(dir, list) {
3333
fs.readdirSync(dir).forEach(file => {
3434
let filePath = path.join(dir, file);
3535
let isDirectory = fs.lstatSync(filePath).isDirectory()
36-
let type = isDirectory ? 'dir' : 'file'
36+
let type = isDirectory ? 'folder' : 'file'
3737
if (isDirectory) {
3838
traverseDir(filePath, list);
3939
}

ui/arduino2/store.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ async function store(state, emitter) {
696696
if (file.type === 'folder') {
697697

698698
let serialPath = await serial.getFullPath('/', state.boardNavigationPath, file.fileName)
699-
log('deleteBoardFolder', serialPath)
699+
// log('deleteBoardFolder', serialPath)
700700
await deleteBoardFolder(serialPath)
701701
await serial.createFolder(serialPath)
702702
const sourceDiskPath = disk.getFullPath(state.diskNavigationRoot, state.diskNavigationPath, file.fileName)
@@ -705,7 +705,7 @@ async function store(state, emitter) {
705705
const fsItem = uploadTree[i]
706706
const strippedPath = fsItem.filePath.split(sourceDiskPath)[1]
707707
let nestedSerialPath = serialPath + strippedPath
708-
if(fsItem.type === 'dir'){
708+
if(fsItem.type === 'folder'){
709709
await serial.createFolder(nestedSerialPath)
710710
}else{
711711
const diskPath = fsItem.filePath
@@ -719,7 +719,6 @@ async function store(state, emitter) {
719719
)
720720
}
721721
}
722-
const confirmAction = alert(`Folder transfer not yet available`)
723722
continue
724723
}
725724
await serial.uploadFile(
@@ -759,26 +758,34 @@ async function store(state, emitter) {
759758
state.currentFSItem = file.fileName
760759
emitter.emit('render')
761760
const folder_path = serial.getFullPath('/', state.boardNavigationPath, file.fileName)
761+
// log('folder_path', folder_path)
762762
let command = microPythonFShelpers
763763
command += microPythonFileTree
764764
command += `print_file_tree('${folder_path}')`
765765
let output = await serial.run(command)
766+
// console.log(output)
766767
output = extract(output)
767768
output = output.replace(/'/g, '"')
768769
output = output.split('OK')
769770
let files = JSON.parse(output)
771+
772+
// console.log(files)
770773
for(f in files){
771774
const sourcePath = (files[f][1])
772775
const type = files[f][3]
773-
const sourceRelativePath = sourcePath.split(state.boardNavigationPath)[1]
776+
const strippedPath = sourcePath.slice(sourcePath.indexOf(state.boardNavigationPath) + state.boardNavigationPath.length)
777+
// console.log('sourcePath:', state.boardNavigationPath)
778+
// console.log('strippedPath', sourcePath, strippedPath)
774779
if(type === 'folder'){
775-
const newFolderPath = disk.getFullPath(state.diskNavigationRoot, state.diskNavigationPath,`/${sourceRelativePath}`)
776-
state.currentFSItem = file.fileName
780+
const newFolderPath = disk.getFullPath(state.diskNavigationRoot, state.diskNavigationPath,`${strippedPath}`)
781+
// console.log('create new folder', sourcePath, newFolderPath)
782+
state.currentFSItem = f.fileName
777783
state.transferringProgress = null
778784
emitter.emit('render')
779785
await disk.createFolder(newFolderPath)
780786
}else{
781-
const fileDestinationPath = disk.getFullPath(state.diskNavigationRoot, state.diskNavigationPath,`/${sourceRelativePath}`)
787+
const fileDestinationPath = disk.getFullPath(state.diskNavigationRoot,state.diskNavigationPath, `${strippedPath}`)
788+
// console.log('download file', sourcePath, fileDestinationPath)
782789
state.currentFSItem = file.fileName
783790
state.transferringProgress = null
784791
emitter.emit('render')

0 commit comments

Comments
 (0)