Fix: handle preview download errors and Unix metadata keys
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
This commit is contained in:
1 parent
6cb779ef70
commit
bcd7ee692a
6 files changed
+70
-9
No files matched your search
@@ -1088,6 +1088,16 @@ void CFileManagerDlg::OnReceiveComplete()
|
||||
delete r;
|
||||
break;
|
||||
}
|
||||
case TOKEN_DOWNLOAD_ERROR: { // 预览下载无可用文件(客户端在文件管理器子连接上回报)
|
||||
LPBYTE buf = m_ContextObject->m_DeCompressionBuffer.GetBuffer(0);
|
||||
ULONG len = m_ContextObject->m_DeCompressionBuffer.GetBufferLen();
|
||||
DWORD err = 0;
|
||||
if (len >= 5) memcpy(&err, buf + 1, sizeof(err));
|
||||
CString msg;
|
||||
msg.FormatL("预览下载失败(错误码 %u)", err);
|
||||
CFilePreviewMgr::Instance().FailForHwnd(m_hWnd, std::string((LPCSTR)msg));
|
||||
break;
|
||||
}
|
||||
case TOKEN_FILE_LIST: // 文件列表
|
||||
try {
|
||||
FixedRemoteFileList
|
||||
@@ -1591,7 +1601,9 @@ void CFileManagerDlg::FixedRemoteFileList(BYTE *pbBuffer, DWORD dwBufferLen)
|
||||
RemoteMeta meta;
|
||||
meta.size = (uint64_t)dwFileSizeHigh * (MAXDWORD + 1ULL) + dwFileSizeLow;
|
||||
meta.mtimeMs = FileTimeToUnixMs(ftm_strReceiveLocalFileTime);
|
||||
CString full = m_Remote_Path + pszFileName;
|
||||
// key 必须与双击时一致:用列表里实际显示的 ANSI/GBK 文本,
|
||||
// 不能用协议原始字节(LNX/MAC 是 UTF-8,双击取回是 GBK)。
|
||||
CString full = m_Remote_Path + m_list_remote.GetItemText(nItem, 0);
|
||||
m_RemoteMeta[std::string((LPCSTR)full)] = meta;
|
||||
}
|
||||
}
|
||||
@@ -1698,7 +1710,13 @@ void CFileManagerDlg::FixedRemoteSearchFileList(BYTE *pbBuffer, DWORD dwBufferLe
|
||||
RemoteMeta meta;
|
||||
meta.size = (uint64_t)dwFileSizeHigh * (MAXDWORD + 1ULL) + dwFileSizeLow;
|
||||
meta.mtimeMs = FileTimeToUnixMs(ftLastWrite);
|
||||
m_RemoteMeta[std::string((LPCSTR)csFullPath)] = meta;
|
||||
// 与双击路径拼接保持一致(显示文本,不是协议原始字节)。
|
||||
CString dispName = m_list_remote.GetItemText(nItem, 0);
|
||||
CString dispDir = m_list_remote.GetItemText(nItem, 3);
|
||||
CString full = dispDir;
|
||||
if (!full.IsEmpty() && full.Right(1) != "\\") full += "\\";
|
||||
full += dispName;
|
||||
m_RemoteMeta[std::string((LPCSTR)full)] = meta;
|
||||
}
|
||||
|
||||
pList += 16;
|
||||
@@ -3201,6 +3219,9 @@ LRESULT CFileManagerDlg::OnRecvFileV2Chunk(WPARAM wParam, LPARAM /*lParam*/)
|
||||
dlg->m_bKeepConnection = TRUE; // FileManager 子连接复用,对话框关闭时不断开
|
||||
entry = { dlg->GetSafeHwnd(), dlg };
|
||||
}
|
||||
// Unix 同连接路径没有 MessageHandle 钩子,在这里把进度框绑到预览请求,
|
||||
// 供看门狗超时关闭它。
|
||||
CFilePreviewMgr::Instance().BindProgressWindow(m_ContextObject, entry.first);
|
||||
|
||||
// 落盘
|
||||
std::string hash = GetPwdHash(), hmac = GetHMAC(100);
|
||||
@@ -3523,10 +3544,18 @@ void CFileManagerDlg::OnRefresh()
|
||||
|
||||
void CFileManagerDlg::OnLocalOpen()
|
||||
{
|
||||
// TODO: Add your command handler code here
|
||||
CString str;
|
||||
str = m_Local_Path + m_list_local.GetItemText(m_list_local.GetSelectionMark(), 0);
|
||||
ShellExecute(NULL, "open", str, NULL, NULL, SW_SHOW);
|
||||
int nItem = m_list_local.GetSelectionMark();
|
||||
if (nItem < 0) return;
|
||||
CString name = m_list_local.GetItemText(nItem, 0);
|
||||
CString full;
|
||||
if (m_bLocalSearchResults) {
|
||||
full = m_list_local.GetItemText(nItem, 3);
|
||||
if (!full.IsEmpty() && full.Right(1) != "\\") full += "\\";
|
||||
full += name;
|
||||
} else {
|
||||
full = m_Local_Path + name;
|
||||
}
|
||||
OpenLocalPath(full);
|
||||
}
|
||||
|
||||
void CFileManagerDlg::OnRemoteOpenShow()
|
||||
|
||||
Reference in new issue
Block a user