Feature: preview remote files on file manager double-click
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
This commit is contained in:
1 parent
02c22b82a7
commit
3b945d1992
6 files changed
+329
-10
No files matched your search
@@ -78,6 +78,7 @@
|
||||
#include "LogSearchBar.h"
|
||||
#include <ServerServiceWrapper.h>
|
||||
#include "CDlgFileSend.h"
|
||||
#include "FilePreview.h"
|
||||
#include "CClientListDlg.h"
|
||||
#include "CUpdateDlg.h"
|
||||
#include "CLicenseDlg.h"
|
||||
@@ -7671,6 +7672,20 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
break;
|
||||
}
|
||||
|
||||
// 文件管理器双击预览:首包绑定/门限/逐块路径约束(放在 MCP 拦截之后)。
|
||||
if (len >= sizeof(FileChunkPacketV2) && pkt->dstClientID == 0) {
|
||||
ULONG nameLen = (ULONG)pkt->nameLength;
|
||||
if (len >= (ULONG)(sizeof(FileChunkPacketV2) + nameLen)) {
|
||||
const char* name = (const char*)(szBuffer + sizeof(FileChunkPacketV2));
|
||||
uint64_t previewTid = 0;
|
||||
if (!CFilePreviewMgr::Instance().ObserveChunk(ContextObject, pkt, name,
|
||||
len, &previewTid)) {
|
||||
ContextObject->CancelIO();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pkt->dstClientID == 0) {
|
||||
// 目标是主控端:本地接收
|
||||
if (ContextObject->hDlg == NULL) {
|
||||
@@ -7679,6 +7694,7 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
dlg->ShowWindow(SW_HIDE);
|
||||
ContextObject->hDlg = dlg;
|
||||
ContextObject->hWnd = dlg->GetSafeHwnd();
|
||||
CFilePreviewMgr::Instance().BindProgressWindow(ContextObject, dlg->GetSafeHwnd());
|
||||
}
|
||||
// OnReceiveComplete() 会根据 cmd 字节自动判断 V1/V2
|
||||
DialogBase* dlg = (DialogBase*)ContextObject->hDlg;
|
||||
@@ -7950,6 +7966,7 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
bool verifyOk = HandleFileCompleteV2((char*)szBuffer, len, 0);
|
||||
Mprintf("[V2] 文件校验%s: transferID=%llu, fileIndex=%u\n",
|
||||
verifyOk ? "通过" : "失败", pkt->transferID, pkt->fileIndex);
|
||||
CFilePreviewMgr::Instance().OnComplete(ContextObject, pkt, verifyOk);
|
||||
} else {
|
||||
// C2C:转发到目标客户端
|
||||
context* dstCtx = FindHost(pkt->dstClientID);
|
||||
|
||||
Reference in new issue
Block a user