[GH-ISSUE #2976] trz上传文件后 文件不完整了 #1959

Closed
opened 2026-02-27 00:05:29 +03:00 by kerem · 22 comments
Owner

Originally created by @xxoxx on GitHub (Sep 12, 2023).
Original GitHub issue: https://github.com/electerm/electerm/issues/2976

Electerm Version and download file extension(Electerm版本和下载文件后缀)

electerm-1.32.6-mac-x64.dmg

Platform detail (平台详情)

mac x86

What steps will reproduce the bug?(重新问题的详细步骤)

并不是每个文件都会这样
样本文件: https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
样本文件md5:bef7015ca2fd7f19057cad0262d970d2

通过trz上传后, 文件的md5sum发生改变,造成文件不能正常解压

另外我通过 trzsz-iterm2 的trz上传是正常的 md5值是没有发生改变的, 可排除trzsz这个协议本身的问题

What should have happened?(期望的结果)

正常上传

Would this happen in other terminal app(是否能够在其他同类软件重现这个问题)

No response

Additional information(其他任何相关信息)

No response

Originally created by @xxoxx on GitHub (Sep 12, 2023). Original GitHub issue: https://github.com/electerm/electerm/issues/2976 ### Electerm Version and download file extension(Electerm版本和下载文件后缀) electerm-1.32.6-mac-x64.dmg ### Platform detail (平台详情) mac x86 ### What steps will reproduce the bug?(重新问题的详细步骤) 并不是每个文件都会这样 样本文件: https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz 样本文件md5:bef7015ca2fd7f19057cad0262d970d2 通过trz上传后, 文件的md5sum发生改变,造成文件不能正常解压 另外我通过 trzsz-iterm2 的trz上传是正常的 md5值是没有发生改变的, 可排除trzsz这个协议本身的问题 ### What should have happened?(期望的结果) 正常上传 ### Would this happen in other terminal app(是否能够在其他同类软件重现这个问题) _No response_ ### Additional information(其他任何相关信息) _No response_
kerem 2026-02-27 00:05:29 +03:00
Author
Owner

@xxoxx commented on GitHub (Sep 12, 2023):

图片
<!-- gh-comment-id:1715280184 --> @xxoxx commented on GitHub (Sep 12, 2023): <img width="1405" alt="图片" src="https://github.com/electerm/electerm/assets/8625218/bb2b9542-efef-4ba3-8142-991600474712">
Author
Owner

@zxdong262 commented on GitHub (Sep 12, 2023):

@lonnywong 可以帮助看看吗

<!-- gh-comment-id:1715907802 --> @zxdong262 commented on GitHub (Sep 12, 2023): @lonnywong 可以帮助看看吗
Author
Owner

@lonnywong commented on GitHub (Sep 12, 2023):

@lonnywong 可以帮助看看吗

@zxdong262 你可以复现不?我有空时看看。

<!-- gh-comment-id:1715920804 --> @lonnywong commented on GitHub (Sep 12, 2023): > @lonnywong 可以帮助看看吗 @zxdong262 你可以复现不?我有空时看看。
Author
Owner

@lonnywong commented on GitHub (Sep 12, 2023):

@xxoxx 看看文件大小分别是什么,差多少?

<!-- gh-comment-id:1716673402 --> @lonnywong commented on GitHub (Sep 12, 2023): @xxoxx 看看文件大小分别是什么,差多少?
Author
Owner

@zxdong262 commented on GitHub (Sep 12, 2023):

@xxoxx 看看文件大小分别是什么,差多少?

我试了,任意文件trz上传后都会md5不一样,ls -al查看文件大小都一样 mac->ubuntu server

<!-- gh-comment-id:1716725995 --> @zxdong262 commented on GitHub (Sep 12, 2023): > @xxoxx 看看文件大小分别是什么,差多少? 我试了,任意文件trz上传后都会md5不一样,`ls -al`查看文件大小都一样 mac->ubuntu server
Author
Owner

@xxoxx commented on GitHub (Sep 12, 2023):

图片
@lonnywong 文件大小都一样, 但是md5值不一样, 可能针对普通文本文档没什么问题, 但是针对压缩包文件, 有一点点差异就不能正常解压

<!-- gh-comment-id:1716729047 --> @xxoxx commented on GitHub (Sep 12, 2023): ![图片](https://github.com/electerm/electerm/assets/8625218/5605ee54-1bb5-46d3-90c1-e753c87e4c23) @lonnywong 文件大小都一样, 但是md5值不一样, 可能针对普通文本文档没什么问题, 但是针对压缩包文件, 有一点点差异就不能正常解压
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

@xxoxx 把两个文件放到同一台机,然后 diff 看看。可以用下面的命令之一:

diff -y <(xxd foo1.bin) <(xxd foo2.bin)

vimdiff <(xxd foo1.bin) <(xxd foo2.bin)

https://superuser.com/questions/125376/how-do-i-compare-binary-files-in-linux

<!-- gh-comment-id:1716744297 --> @lonnywong commented on GitHub (Sep 13, 2023): @xxoxx 把两个文件放到同一台机,然后 diff 看看。可以用下面的命令之一: ```sh diff -y <(xxd foo1.bin) <(xxd foo2.bin) vimdiff <(xxd foo1.bin) <(xxd foo2.bin) ``` https://superuser.com/questions/125376/how-do-i-compare-binary-files-in-linux
Author
Owner

@zxdong262 commented on GitHub (Sep 13, 2023):

@xxoxx 把两个文件放到同一台机,然后 diff 看看。可以用下面的命令之一:

diff -y <(xxd foo1.bin) <(xxd foo2.bin)

vimdiff <(xxd foo1.bin) <(xxd foo2.bin)


https://superuser.com/questions/125376/how-do-i-compare-binary-files-in-linux

Screen Shot 2023-09-13 at 08 19 48

cat test.js 显示为空

<!-- gh-comment-id:1716756426 --> @zxdong262 commented on GitHub (Sep 13, 2023): > @xxoxx 把两个文件放到同一台机,然后 diff 看看。可以用下面的命令之一: > > ```shell > diff -y <(xxd foo1.bin) <(xxd foo2.bin) > > vimdiff <(xxd foo1.bin) <(xxd foo2.bin) > ``` > > https://superuser.com/questions/125376/how-do-i-compare-binary-files-in-linux ![Screen Shot 2023-09-13 at 08 19 48](https://github.com/electerm/electerm/assets/1641949/2b4d3912-ac4b-44a2-b057-002a1b6db363) `cat test.js` 显示为空
Author
Owner

@xxoxx commented on GitHub (Sep 13, 2023):

图片
@lonnywong

<!-- gh-comment-id:1716758712 --> @xxoxx commented on GitHub (Sep 13, 2023): ![图片](https://github.com/electerm/electerm/assets/8625218/04a80b48-0b2d-4971-b6ef-803fe41f0076) @lonnywong
Author
Owner

@xxoxx commented on GitHub (Sep 13, 2023):

好像是付了个相同文件大小的空文件上去呢?

<!-- gh-comment-id:1716759164 --> @xxoxx commented on GitHub (Sep 13, 2023): 好像是付了个相同文件大小的空文件上去呢?
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

看来是某种原因导致读文件失败了,然后又没有抛出异常,就继续往下执行了,最终上传到远程的就全是 00。

<!-- gh-comment-id:1716770723 --> @lonnywong commented on GitHub (Sep 13, 2023): 看来是某种原因导致读文件失败了,然后又没有抛出异常,就继续往下执行了,最终上传到远程的就全是 00。
Author
Owner

@xxoxx commented on GitHub (Sep 13, 2023):

什么时候能修复呢? 现在严重影响了工作效率了

<!-- gh-comment-id:1716871536 --> @xxoxx commented on GitHub (Sep 13, 2023): 什么时候能修复呢? 现在严重影响了工作效率了
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

@zxdong262

sandboxcontextIsolation 是否可以改成 false? 这样改可能会快一些。

trzsz 的例子中是这样的:
github.com/trzsz/trzsz.js@9320e1ccc6/examples/electron/main.js (L18-L22)

tabby 是这样的:
github.com/Eugeny/tabby@3ce2bb68c6/app/lib/window.ts (L66-L71)

<!-- gh-comment-id:1716936885 --> @lonnywong commented on GitHub (Sep 13, 2023): @zxdong262 `sandbox` 和 `contextIsolation` 是否可以改成 `false`? 这样改可能会快一些。 trzsz 的例子中是这样的: https://github.com/trzsz/trzsz.js/blob/9320e1ccc6663bb628821ae871c5897f986680e2/examples/electron/main.js#L18-L22 tabby 是这样的: https://github.com/Eugeny/tabby/blob/3ce2bb68c6ade178cfb48c4027fcd0935712ea0f/app/lib/window.ts#L66-L71
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

image

@zxdong262 返回的长度 45 是符合预期的,但是入参 uint8 这个 buffer 没有被赋值,估计是 ipc 调用时,内容读到另一个 buffer 去了。

<!-- gh-comment-id:1716949184 --> @lonnywong commented on GitHub (Sep 13, 2023): ![image](https://github.com/electerm/electerm/assets/20320324/4e659bd3-3819-49d7-9d90-21ee1f807287) @zxdong262 返回的长度 45 是符合预期的,但是入参 uint8 这个 buffer 没有被赋值,估计是 ipc 调用时,内容读到另一个 buffer 去了。
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

什么时候能修复呢? 现在严重影响了工作效率了

@xxoxx 可以试着先用旧一些版本的 electerm 。

<!-- gh-comment-id:1716950252 --> @lonnywong commented on GitHub (Sep 13, 2023): > 什么时候能修复呢? 现在严重影响了工作效率了 @xxoxx 可以试着先用旧一些版本的 electerm 。
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

@zxdong262 我有计划把 fs.readSync 换成 fs.read 函数的,其他带 Sync 后缀的也一并换成不带 Sync 后缀的,不过一直没空去写。

https://nodejs.org/api/fs.html#fsreadfd-buffer-offset-length-position-callback

<!-- gh-comment-id:1716961081 --> @lonnywong commented on GitHub (Sep 13, 2023): @zxdong262 我有计划把 `fs.readSync` 换成 `fs.read` 函数的,其他带 `Sync` 后缀的也一并换成不带 `Sync` 后缀的,不过一直没空去写。 https://nodejs.org/api/fs.html#fsreadfd-buffer-offset-length-position-callback
Author
Owner

@zxdong262 commented on GitHub (Sep 13, 2023):

我知道怎么处理了

image

@zxdong262 返回的长度 45 是符合预期的,但是入参 uint8 这个 buffer 没有被赋值,估计是 ipc 调用时,内容读到另一个 buffer 去了。

我知道怎么处理了,
ipc 不能对原始数据进行修改,只是把传入参数修改了,得返回才行,得暂时用个临时的修改版trzsz.js来处理,我看看有空我会提交个pr

<!-- gh-comment-id:1717096965 --> @zxdong262 commented on GitHub (Sep 13, 2023): 我知道怎么处理了 > ![image](https://user-images.githubusercontent.com/20320324/267540450-4e659bd3-3819-49d7-9d90-21ee1f807287.png) > > @zxdong262 返回的长度 45 是符合预期的,但是入参 uint8 这个 buffer 没有被赋值,估计是 ipc 调用时,内容读到另一个 buffer 去了。 我知道怎么处理了, ipc 不能对原始数据进行修改,只是把传入参数修改了,得返回才行,得暂时用个临时的修改版trzsz.js来处理,我看看有空我会提交个pr
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

我知道怎么处理了

@zxdong262 现在你是直接将所有参数转发,如果 fs.readSync 用一个函数包起来,那应该可以不改 trzsz.js。其他不受影响的函数,可以保留直接转发。

<!-- gh-comment-id:1717104329 --> @lonnywong commented on GitHub (Sep 13, 2023): > 我知道怎么处理了 > @zxdong262 现在你是直接将所有参数转发,如果 `fs.readSync` 用一个函数包起来,那应该可以不改 `trzsz.js`。其他不受影响的函数,可以保留直接转发。
Author
Owner

@lonnywong commented on GitHub (Sep 13, 2023):

@zxdong262 fs.readSync 的参数是固定的,你把它定义出来,然后就知道怎么实现了。

https://nodejs.org/api/fs.html#fsreadsyncfd-buffer-offset-length-position

readSync(fd, buffer, offset, length, position)
<!-- gh-comment-id:1717115601 --> @lonnywong commented on GitHub (Sep 13, 2023): @zxdong262 `fs.readSync` 的参数是固定的,你把它定义出来,然后就知道怎么实现了。 https://nodejs.org/api/fs.html#fsreadsyncfd-buffer-offset-length-position ```js readSync(fd, buffer, offset, length, position) ```
Author
Owner

@zxdong262 commented on GitHub (Sep 13, 2023):

我知道怎么处理了

@zxdong262 现在你是直接将所有参数转发,如果 fs.readSync 用一个函数包起来,那应该可以不改 trzsz.js。其他不受影响的函数,可以保留直接转发。

明白了,感谢指导~

<!-- gh-comment-id:1717219469 --> @zxdong262 commented on GitHub (Sep 13, 2023): > > 我知道怎么处理了 > > @zxdong262 现在你是直接将所有参数转发,如果 `fs.readSync` 用一个函数包起来,那应该可以不改 `trzsz.js`。其他不受影响的函数,可以保留直接转发。 明白了,感谢指导~
Author
Owner

@zxdong262 commented on GitHub (Sep 13, 2023):

什么时候能修复呢? 现在严重影响了工作效率了

已发布新版,修复了

<!-- gh-comment-id:1717461259 --> @zxdong262 commented on GitHub (Sep 13, 2023): > 什么时候能修复呢? 现在严重影响了工作效率了 已发布新版,修复了
Author
Owner

@xxoxx commented on GitHub (Sep 13, 2023):

@zxdong262 已经升级了, 经验证,的确可用了,感谢

<!-- gh-comment-id:1717527338 --> @xxoxx commented on GitHub (Sep 13, 2023): @zxdong262 已经升级了, 经验证,的确可用了,感谢
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/electerm#1959
No description provided.