Feature: query the remote SHA-256 before previewing

When the main connection advertises CLIENT_CAP_FILE_HASH, double-click
sends COMMAND_FILE_HASH first and continues from the async
TOKEN_FILE_HASH response (posted to the UI thread). A matching SHA-256
opens the cached copy without a transfer, including content found under
a different remote path; the new path is added to the index. Too-large
and error responses are handled, and a 5 second timeout falls back to the
P1 size/mtime path.

The response parser is based on FileHashResponseHeader and the echoed
request path; pending state is cleared on close and the hash timer is
killed with the dialog.

Verified with the Debug server and client: a 1 MiB file was hashed,
transferred and cached under its SHA-256; an identical copy at a second
path hit the cache with no new transfer or stream connection.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-12-05 15:43:12 +01:00
1 parent ea5d69d1c0
commit 6cb779ef70
7 files changed
+168 -5

No files matched your search

+1
View File
@@ -2374,3 +2374,4 @@ MCP
无法获取文件信息,请刷新目录后重试=無法取得檔案資訊,請重新整理目錄後重試
文件较大,不支持预览:%s(%llu MB,上限 %u MB)=檔案過大,不支援預覽:%s(%llu MB,上限 %u MB)
正在预览 %s ...=正在預覽 %s ...
获取远程文件信息失败(错误码 %u)=取得遠端檔案資訊失敗(錯誤碼 %u)