fix(core): 修复在线版ampy写文件异常

This commit is contained in:
王立帮
2025-10-03 13:13:13 +08:00
parent 6dd41bdcd4
commit 27dd669932

View File

@@ -237,8 +237,10 @@ class AmpyExt extends Ampy {
}
await this.exec(`file = open('${filename}', 'wb')`, timeout);
let buffer = null;
if (typeof data === 'string') {
if (data.constructor === String) {
buffer = this.#device_.encode(data);
} else if (data.constructor === ArrayBuffer) {
buffer = new Uint8Array(data);
} else {
buffer = data;
}
@@ -255,7 +257,7 @@ class AmpyExt extends Ampy {
}
await this.exec(`file.write(b'${writeStr}')`, timeout);
}
await this.exec(`file.close()`, timeout);
await this.exec('file.close()', timeout);
}
async ls(directory = '/', longFormat = true, recursive = false, timeout = 5000) {