Skip to content

Commit 953f403

Browse files
authored
Merge pull request #185 from arduino/fix/root-detection
Fix/root detection
2 parents 1a2b11d + 3915443 commit 953f403

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

ui/arduino/helpers.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import os
22
import json
3-
os.chdir('/')
3+
import sys
4+
5+
def get_root():
6+
if '/flash' in sys.path:
7+
return '/flash'
8+
else:
9+
return '/'
10+
411
def is_directory(path):
512
return True if os.stat(path)[0] == 0x4000 else False
613

@@ -18,6 +25,9 @@ def get_all_files(path, array_of_files = []):
1825
return array_of_files
1926

2027

28+
def iget_root():
29+
print(get_root(), end='')
30+
2131
def ilist_all(path):
2232
print(json.dumps(get_all_files(path)))
2333

@@ -30,3 +40,5 @@ def delete_folder(path):
3040
if file['type'] == 'folder':
3141
os.rmdir(file['path'])
3242
os.rmdir(path)
43+
44+
os.chdir(get_root())

ui/arduino/store.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ async function store(state, emitter) {
179179
// Connected and ready
180180
state.isConnecting = false
181181
state.isConnected = true
182+
state.boardNavigationPath = await getBoardNavigationPath()
182183
updateMenu()
183184
if (state.view === 'editor' && state.panelHeight <= PANEL_CLOSED) {
184185
state.panelHeight = state.savedPanelHeight
@@ -288,7 +289,10 @@ async function store(state, emitter) {
288289
}
289290
emitter.emit('open-panel')
290291
emitter.emit('render')
291-
await serialBridge.getPrompt()
292+
if (state.isConnected) {
293+
await serialBridge.getPrompt()
294+
}
295+
292296
})
293297
emitter.on('reset', async () => {
294298
log('reset')
@@ -606,7 +610,7 @@ async function store(state, emitter) {
606610
}
607611
await serialBridge.saveFileContent(
608612
serialBridge.getFullPath(
609-
'/',
613+
state.boardNavigationRoot,
610614
state.boardNavigationPath,
611615
fileNameParameter
612616
),
@@ -785,7 +789,7 @@ async function store(state, emitter) {
785789
if (file.source === 'board') {
786790
await serialBridge.removeFile(
787791
serialBridge.getFullPath(
788-
'/',
792+
state.boardNavigationRoot,
789793
state.boardNavigationPath,
790794
file.fileName
791795
)
@@ -1695,6 +1699,23 @@ async function getAvailablePorts() {
16951699
return await serialBridge.loadPorts()
16961700
}
16971701

1702+
async function getBoardNavigationPath() {
1703+
let output = await serialBridge.execFile(await getHelperFullPath())
1704+
output = await serialBridge.run(`iget_root()`)
1705+
let boardRoot = ''
1706+
try {
1707+
// Extracting the json output from serial response
1708+
output = output.substring(
1709+
output.indexOf('OK')+2,
1710+
output.indexOf('\x04')
1711+
)
1712+
boardRoot = output
1713+
} catch (e) {
1714+
log('error', output)
1715+
}
1716+
return boardRoot
1717+
}
1718+
16981719
async function getBoardFiles(path) {
16991720
await serialBridge.getPrompt()
17001721
let files = await serialBridge.ilistFiles(path)

ui/arduino/views/components/new-file-dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function NewFileDialog(state, emit) {
6565
`
6666

6767
if (state.isNewFileDialogOpen) {
68-
const el = newFileDialog.querySelector('#dialog-new-file .dialog-contents > input')
68+
const el = newFileDialog.querySelector('#dialog-new-file .dialog-content > input')
6969
if (el) {
7070
el.focus()
7171
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy