Only consume a TOKEN_FILE_HASH response whose echoed path matches the
pending request, and kill the 5 s timer only in that branch. A late,
duplicate or malformed response previously killed the timer but left
m_pendingHash set, so every later double-click in that window was
rejected as "another preview is in progress" until the dialog closed.
A mismatched response is now ignored and the timer still falls back to
the size/mtime path, which clears the pending state.
Co-Authored-By: deepseek-flash
Consume TOKEN_DOWNLOAD_ERROR in the file manager and fail the matching
preview request with the client's win32 code instead of sending
COMMAND_EXCEPTION and leaving the request to the 15 s watchdog.
Key the exact size/mtime metadata by the list's displayed ANSI/GBK text,
not the raw protocol bytes: Linux/macOS send UTF-8 names while GetItemText
returns the process ACP, so non-ASCII files previously missed the metadata
lookup and could not start a preview.
Bind the Unix progress dialog to the preview request so a stalled transfer
closes it on timeout; save the index after LRU eviction; make the local
right-click Open honour search-result paths; reject over-long received
names; and defer abandoned temp-dir deletion to the watchdog.
The new download-error and hash-error strings are added to en_US, zh_TW
and de_DE.
Co-Authored-By: deepseek-flash
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
Release the DeviceTransferGate only after leaving m_PendingMutex in the
three MCP begin paths, matching the documented gate -> pending -> xfer
order (the gate mutex is brief, but this keeps the order explicit and
avoids future nesting mistakes).
Also short-circuit ObserveChunk when there are no preview requests or
tombstones, so ordinary V2 chunk paths do not scan the preview maps.
Co-Authored-By: deepseek-flash
Add the preview strings to en_US, zh_TW and de_DE (GBK, no '=' in keys;
German uses ASCII transliterations where GBK cannot encode umlauts), and
pass the cached entry's SHA-256 back to the open helper so the executable
confirmation shows the actual hash on a cache hit.
Honour PreviewEnabled=0 by leaving double-click unchanged, and document
the preview plus COMMAND_FILE_HASH capability in the client matrix.
Co-Authored-By: deepseek-flash
Preview and MCP must not run file transfers on one device at the same
time: MCP's stream interceptor is device-keyed and not tool-aware, so a
preview stream arriving while an upload/C2C session exists would be
swallowed. Claim the shared DeviceTransferGate in all three MCP entry
points (download/read, upload_file, copy_files_c2c) before touching the
pending/file-transfer registries, and release it in ClearFileTransfer.
C2C claims both src and dst atomically; a failed registry check releases
the claim before returning. The gate is acquired before m_PendingMutex
and m_FileXferMutex to keep the documented order.
Co-Authored-By: deepseek-flash
Double-clicking a local file now opens it, and a remote file is fetched
through the existing V2 transfer into Preview\<clientKey>\<hash16>_<basename>
and opened with the default program. The cache index is checked first by
remote path + size/mtime; a transfer records the complete packet's SHA-256
and verifies it before moving the file into the cache.
Hook both V2 receive paths: the Windows stream sub-connection observes
the first chunk in MessageHandle and later chunks in CDlgFileSend; the
Unix/Android same-connection path observes in OnRecvFileV2Chunk. A failed
basename bound or path escape cancels the stream. The filename is now
bounded by the packet's nameLength (it is not NUL-terminated), which also
fixes the 1 MiB transfer case where trailing bytes were misread as a path.
Search-result lists use column 3 as the directory and get their own
result flag; the exact size/FILETIME from the listing feeds the 8 MiB gate.
Remote executables require a confirmation before ShellExecute. A Debug-only
WM_APP+0x123 hook drives the same double-click handler for end-to-end tests.
Verified with a Debug x64 server and client: a 1 MiB remote file was
transferred, SHA-256 verified, cached and indexed; a second double-click
hit the cache without a transfer.
Co-Authored-By: deepseek-flash
Add FilePreview.h/.cpp with the non-UI half of the double-click preview:
a flat per-client cache (Preview\<clientKey>\<hash16>_<basename>), a
per-client index keyed by remote path and SHA-256, size/mtime metadata
hits, the 8 MiB gate, empty-file handling, LRU caps, and the executable
confirmation plus ShellExecute helper.
DeviceTransferGate is the shared device-level claim used by preview and
the MCP file-transfer entry points so one device can only run one file
transfer at a time; C2C claims both src and dst. The receive hooks
(ObserveChunk/OnComplete) are implemented here and called by the file
manager paths in the next commit.
Co-Authored-By: deepseek-flash
Add COMMAND_FILE_HASH/TOKEN_FILE_HASH (182/183) and the
CLIENT_CAP_FILE_HASH capability so the server can ask a client for a
single file's exact size, mtime and SHA-256 without transferring it.
This is the P2 half of the double-click preview design; old clients do
not advertise the capability and are skipped by the caller.
Windows hashes with BCrypt through the existing VerifyV2 helper; Unix
and Android stream Sha256 while reading. Both clamp the peer-supplied
maxBytes to FILE_PREVIEW_MAX_BYTES, echo the original request path bytes
for correlation, and return TOO_LARGE without reading the file. The Unix
loop also verifies the bytes hashed match stat() so a file changed
mid-read reports an error instead of a mismatched hash.
No existing command changes; the new values are explicit and the four
DefaultCaps branches advertise the capability.
Co-Authored-By: deepseek-flash
Describe the finalized design for previewing remote files from the
file manager: reuse V2 transfer on both the Windows stream sub-connection
and the Unix same-connection path, cache files flat under
Preview\<clientKey>\<hash16>_<basename>, keep a per-client index keyed by
SHA-256, cap single files with FILE_PREVIEW_MAX_BYTES, and require a
confirmation before opening remote executables. Hash queries are an
optional P2 capability; P1 uses the exact size/mtime from the listing.
Co-Authored-By: deepseek-flash