Skip to content

Commit 5c42aeb

Browse files
authored
Merge pull request #166 from arduino/development
Fixing file save bug > 0.11.1
2 parents 3d4a54b + 187424b commit 5c42aeb

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

backend/ipc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module.exports = function registerIPCHandlers(win, ipcMain, app, dialog) {
145145
})
146146

147147
ipcMain.handle('serial', (event, command, ...args) => {
148-
console.debug('Handling IPC serial command:', command, ...args)
148+
// console.debug('Handling IPC serial command:', command, ...args)
149149
return serial[command](...args)
150150
})
151151
}

backend/serial/serial-bridge.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,23 @@ const SerialBridge = {
5353
return await ipcRenderer.invoke('serial', 'removeFile', file)
5454
},
5555
saveFileContent: async (filename, content, dataConsumer) => {
56-
return await ipcRenderer.invoke('serial', 'saveFileContent', filename, content, dataConsumer)
56+
if (ipcRenderer.listeners("serial-on-file-save-progress").length > 0) {
57+
ipcRenderer.removeAllListeners("serial-on-file-save-progress")
58+
}
59+
ipcRenderer.on('serial-on-file-save-progress', (event, progress) => {
60+
dataConsumer(progress)
61+
})
62+
return await ipcRenderer.invoke('serial', 'saveFileContent', filename, content)
5763
},
5864
uploadFile: async (src, dest, dataConsumer) => {
59-
return await ipcRenderer.invoke('serial', 'uploadFile', src, dest, dataConsumer)
65+
if (ipcRenderer.listeners("serial-on-upload-progress").length > 0) {
66+
ipcRenderer.removeAllListeners("serial-on-upload-progress")
67+
}
68+
69+
ipcRenderer.on('serial-on-upload-progress', (event, progress) => {
70+
dataConsumer(progress)
71+
})
72+
return await ipcRenderer.invoke('serial', 'uploadFile', src, dest)
6073
},
6174
downloadFile: async (src, dest) => {
6275
let contents = await ipcRenderer.invoke('serial', 'loadFile', src)

backend/serial/serial.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const MicroPython = require('micropython.js')
2+
const path = require('path')
23

34
class Serial {
45
constructor(win = null) {
@@ -79,12 +80,16 @@ class Serial {
7980
return await this.board.fs_rm(file)
8081
}
8182

82-
async saveFileContent(filename, content, dataConsumer) {
83-
return await this.board.fs_save(content || ' ', filename, dataConsumer)
83+
async saveFileContent(filename, content) {
84+
return await this.board.fs_save(content || ' ', filename, (progress) => {
85+
this.win.webContents.send('serial-on-file-save-progress', progress)
86+
})
8487
}
8588

86-
async uploadFile(src, dest, dataConsumer) {
87-
return await this.board.fs_put(src, dest.replaceAll(path.win32.sep, path.posix.sep), dataConsumer)
89+
async uploadFile(src, dest) {
90+
return await this.board.fs_put(src, dest.replaceAll(path.win32.sep, path.posix.sep), (progress) => {
91+
this.win.webContents.send('serial-on-upload-progress', progress)
92+
})
8893
}
8994

9095
async renameFile(oldName, newName) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "arduino-lab-micropython-ide",
33
"productName": "Arduino Lab for MicroPython",
4-
"version": "0.11.0",
4+
"version": "0.11.1",
55
"description": "Arduino Lab for MicroPython is a project sponsored by Arduino, based on original work by Murilo Polese.\nThis is an experimental pre-release software, please direct any questions exclusively to Github issues.",
66
"main": "index.js",
77
"scripts": {

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