Feature: localize the preview messages and report the cached hash

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
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-12-05 15:32:26 +01:00
1 parent 4d37d85bac
commit 3683b4ebeb
7 files changed
+72 -10

No files matched your search

+3 -3
View File
@@ -1330,14 +1330,14 @@ void CFileManagerDlg::BeginRemotePreview(const CString& fullPath)
std::string basename = (pos == std::string::npos) ? remotePath : remotePath.substr(pos + 1);
std::string clientKey = GetPreviewClientKey(clientID);
std::string outPath, error;
std::string outPath, error, cachedSha;
CFilePreviewMgr::PrepareResult pr = CFilePreviewMgr::Instance().Prepare(
clientID, clientKey, remotePath, basename, meta.size, meta.mtimeMs,
std::string(), m_hWnd, outPath, error);
std::string(), m_hWnd, outPath, error, &cachedSha);
Mprintf("[Preview] prepare result=%d out=%s err=%s\n", (int)pr, outPath.c_str(), error.c_str());
if (pr == CFilePreviewMgr::PrepareCached) {
CFilePreviewMgr::OpenLocalFile(m_hWnd, outPath, remotePath, meta.size, std::string());
CFilePreviewMgr::OpenLocalFile(m_hWnd, outPath, remotePath, meta.size, cachedSha);
return;
}
if (pr != CFilePreviewMgr::PrepareTransfer) {
+6 -2
View File
@@ -121,10 +121,12 @@ CFilePreviewMgr::PrepareResult CFilePreviewMgr::Prepare(
uint64_t clientID, const std::string& clientKey,
const std::string& remotePath, const std::string& basename,
uint64_t size, uint64_t mtimeMs, const std::string& sha256,
HWND notifyHwnd, std::string& outPath, std::string& error)
HWND notifyHwnd, std::string& outPath, std::string& error,
std::string* outSha)
{
outPath.clear();
error.clear();
if (outSha) outSha->clear();
std::string root = RootDir();
if (root.empty()) {
@@ -157,6 +159,7 @@ CFilePreviewMgr::PrepareResult CFilePreviewMgr::Prepare(
}
SaveIndex(clientDir, index);
outPath = localPath;
if (outSha) *outSha = hit.sha256;
return PrepareCached;
}
}
@@ -185,6 +188,7 @@ CFilePreviewMgr::PrepareResult CFilePreviewMgr::Prepare(
SaveIndex(clientDir, index);
EnforceCacheLimits(clientDir, index);
outPath = localPath;
if (outSha) *outSha = sha;
return PrepareCached;
}
@@ -1122,7 +1126,7 @@ bool CFilePreviewMgr::OpenLocalFile(HWND owner, const std::string& localPath,
if (IsExecutableExtension(localPath)) {
CString msg;
msg.Format(_TR("远程文件可能执行代码,确定要打开吗?\n\n远程路径:%s\n大小:%llu 字节\nSHA-256:%s"),
msg.Format(_TR("远程文件可能执行代码,确定要打开吗?(%s,%llu 字节,SHA-256 %s)"),
CString(remotePath.c_str()),
(unsigned long long)size,
CString(sha256.size() >= 16 ? sha256.substr(0, 16).c_str() : sha256.c_str()));
+2 -1
View File
@@ -69,7 +69,8 @@ public:
PrepareResult Prepare(uint64_t clientID, const std::string& clientKey,
const std::string& remotePath, const std::string& basename,
uint64_t size, uint64_t mtimeMs, const std::string& sha256,
HWND notifyHwnd, std::string& outPath, std::string& error);
HWND notifyHwnd, std::string& outPath, std::string& error,
std::string* outSha = nullptr);
// UI 线程:对话框关闭时放弃本窗口的所有预览请求。
void CancelForHwnd(HWND hwnd);
+18
View File
@@ -2352,3 +2352,21 @@ MCP
\n剩余天数包含到期当天;已过期时主控功能可能受限。=\nDie verbleibenden Tage schliessen den Ablauftag ein; nach Ablauf koennen Funktionen eingeschraenkt sein.
重置=Zuruecksetzen
已清空语言包目录设置,已恢复内置语言,重启程序后生效。=Sprachpaketordner-Einstellung geleert; integrierte Sprache wiederhergestellt. Neustart des Programms erforderlich.
无法创建预览缓存目录=Vorschau-Cache-Verzeichnis konnte nicht erstellt werden
无法生成预览请求 ID=Vorschau-Anfrage-ID konnte nicht erzeugt werden
正在预览另一个文件,请稍候=Eine andere Vorschau laeuft bereits, bitte warten
预览文件名越界=Vorschau-Dateiname verlaesst das temporaere Verzeichnis
文件较大或不支持预览=Datei ist zu gross oder kann nicht angezeigt werden
预览文件校验失败=Vorschau-Datei konnte nicht verifiziert werden
文件在传输过程中发生变化,请重试=Datei wurde waehrend der Uebertragung geaendert, bitte erneut versuchen
预览传输停滞,已取消=Vorschau-Uebertragung stockte und wurde abgebrochen
预览传输超时,已取消=Vorschau-Uebertragung ist abgelaufen und wurde abgebrochen
无法写入预览缓存文件=Vorschau-Cache-Datei konnte nicht geschrieben werden
无法打开文件:%s(文件不存在)=Datei kann nicht geoeffnet werden: %s (nicht gefunden)
远程文件可能执行代码,确定要打开吗?(%s,%llu 字节,SHA-256 %s)=Die entfernte Datei kann Code ausfuehren. Trotzdem oeffnen? (%s, %llu Bytes, SHA-256 %s)
安全确认=Sicherheitsbestaetigung
无法打开文件:%s(可能没有关联程序)=Datei kann nicht geoeffnet werden: %s (kein zugeordnetes Programm)
客户端或 V2 开关不支持文件预览(参数 → 文件传输 V2)=Dieser Client oder der V2-Schalter unterstuetzt keine Vorschau (Einstellungen -> Dateiuebertragung V2)
无法获取文件信息,请刷新目录后重试=Dateiinformationen nicht verfuegbar; Verzeichnis aktualisieren und erneut versuchen
文件较大,不支持预览:%s(%llu MB,上限 %u MB)=Datei zu gross fuer die Vorschau: %s (%llu MB, Grenze %u MB)
正在预览 %s ...=Vorschau von %s ...
+18
View File
@@ -2363,3 +2363,21 @@ MCP
\n剩余天数包含到期当天;已过期时主控功能可能受限。=\nRemaining days include the expiry day; some features may be restricted after expiry.
重置=Reset
已清空语言包目录设置,已恢复内置语言,重启程序后生效。=Language pack folder setting cleared; built-in language restored. Restart the program to apply.
无法创建预览缓存目录=Failed to create the preview cache directory
无法生成预览请求 ID=Failed to create a preview request ID
正在预览另一个文件,请稍候=Another preview is in progress, please wait
预览文件名越界=Preview filename escapes the temporary directory
文件较大或不支持预览=File is too large or cannot be previewed
预览文件校验失败=Preview file verification failed
文件在传输过程中发生变化,请重试=File changed during transfer, please retry
预览传输停滞,已取消=Preview transfer stalled and was cancelled
预览传输超时,已取消=Preview transfer timed out and was cancelled
无法写入预览缓存文件=Failed to write the preview cache file
无法打开文件:%s(文件不存在)=Cannot open file: %s (file not found)
远程文件可能执行代码,确定要打开吗?(%s,%llu 字节,SHA-256 %s)=The remote file may execute code. Open it anyway? (%s, %llu bytes, SHA-256 %s)
安全确认=Security confirmation
无法打开文件:%s(可能没有关联程序)=Cannot open file: %s (no associated program)
客户端或 V2 开关不支持文件预览(参数 → 文件传输 V2)=This client or the V2 switch does not support preview (Settings -> File Transfer V2)
无法获取文件信息,请刷新目录后重试=Cannot get file information; refresh the directory and retry
文件较大,不支持预览:%s(%llu MB,上限 %u MB)=File too large to preview: %s (%llu MB, limit %u MB)
正在预览 %s ...=Previewing %s ...
+18
View File
@@ -2356,3 +2356,21 @@ MCP
\n剩余天数包含到期当天;已过期时主控功能可能受限。=\n剩餘天數包含到期當天;已過期時主控功能可能受限。
重置=重設
已清空语言包目录设置,已恢复内置语言,重启程序后生效。=已清空語言包目錄設定,已恢復內建語言,重新啟動程式後生效。
无法创建预览缓存目录=無法建立預覽快取目錄
无法生成预览请求 ID=無法產生預覽請求 ID
正在预览另一个文件,请稍候=正在預覽另一個檔案,請稍候
预览文件名越界=預覽檔名越界
文件较大或不支持预览=檔案過大或不支援預覽
预览文件校验失败=預覽檔案校驗失敗
文件在传输过程中发生变化,请重试=檔案在傳輸過程中發生變化,請重試
预览传输停滞,已取消=預覽傳輸停滯,已取消
预览传输超时,已取消=預覽傳輸逾時,已取消
无法写入预览缓存文件=無法寫入預覽快取檔案
无法打开文件:%s(文件不存在)=無法開啟檔案:%s(檔案不存在)
远程文件可能执行代码,确定要打开吗?(%s,%llu 字节,SHA-256 %s)=遠端檔案可能執行代碼,確定要開啟嗎?(%s,%llu 位元組,SHA-256 %s)
安全确认=安全確認
无法打开文件:%s(可能没有关联程序)=無法開啟檔案:%s(可能沒有關聯程式)
客户端或 V2 开关不支持文件预览(参数 → 文件传输 V2)=此客戶端或 V2 開關不支援檔案預覽(參數 → 檔案傳輸 V2)
无法获取文件信息,请刷新目录后重试=無法取得檔案資訊,請重新整理目錄後重試
文件较大,不支持预览:%s(%llu MB,上限 %u MB)=檔案過大,不支援預覽:%s(%llu MB,上限 %u MB)
正在预览 %s ...=正在預覽 %s ...