cc-viewer 1.6.256 → 1.6.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +35 -11
- package/dist/assets/{App-BxUDsD3t.js → App-eBSb5fy2.js} +1 -1
- package/dist/assets/{MdxEditorPanel-DHU0Ardx.js → MdxEditorPanel-CWT3SFgC.js} +1 -1
- package/dist/assets/{Mobile-Cqm4xH5j.js → Mobile-DdB1mwp_.js} +1 -1
- package/dist/assets/ProxyModal-DGzTxXqd.js +2 -0
- package/dist/assets/index-BGEXf37A.js +2 -0
- package/dist/index.html +1 -1
- package/findcc.js +20 -14
- package/interceptor.js +7 -4
- package/lib/file-api.js +39 -10
- package/lib/git-diff.js +2 -1
- package/lib/interceptor-core.js +3 -2
- package/lib/log-management.js +6 -4
- package/lib/log-watcher.js +3 -1
- package/package.json +1 -1
- package/server.js +118 -36
- package/workspace-registry.js +9 -15
- package/dist/assets/ProxyModal-83mKKqyB.js +0 -2
- package/dist/assets/index-aBYCRImE.js +0 -2
package/workspace-registry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Workspace Registry - 工作区持久化管理
|
|
2
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, readdirSync, openSync, closeSync,
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, readdirSync, openSync, closeSync, unlinkSync } from 'node:fs';
|
|
3
|
+
import { renameSyncWithRetry } from './lib/file-api.js';
|
|
3
4
|
import { join, basename, resolve } from 'node:path';
|
|
4
5
|
import { randomBytes } from 'node:crypto';
|
|
5
6
|
import { LOG_DIR } from './findcc.js';
|
|
@@ -69,19 +70,9 @@ export function saveWorkspaces(list) {
|
|
|
69
70
|
mkdirSync(LOG_DIR, { recursive: true });
|
|
70
71
|
writeFileSync(tmpFile, JSON.stringify({ workspaces: list }, null, 2));
|
|
71
72
|
|
|
72
|
-
// Windows 上 renameSync
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
while (retries > 0) {
|
|
76
|
-
try {
|
|
77
|
-
renameSync(tmpFile, getWorkspacesFile());
|
|
78
|
-
break;
|
|
79
|
-
} catch (err) {
|
|
80
|
-
if (retries === 1) throw err;
|
|
81
|
-
retries--;
|
|
82
|
-
sleep(20);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
73
|
+
// Windows 上 renameSync 可能会因为目标文件存在或被占用而失败。统一走 lib/file-api.js
|
|
74
|
+
// renameSyncWithRetry helper(同款重试策略,跟 interceptor / log-management 一致)。
|
|
75
|
+
renameSyncWithRetry(tmpFile, getWorkspacesFile());
|
|
85
76
|
} catch (err) {
|
|
86
77
|
console.error('[CC Viewer] Failed to save workspaces:', err.message);
|
|
87
78
|
// 尝试清理临时文件
|
|
@@ -101,7 +92,10 @@ export function registerWorkspace(absolutePath) {
|
|
|
101
92
|
const resolvedPath = resolve(absolutePath);
|
|
102
93
|
const projectName = basename(resolvedPath).replace(/[^a-zA-Z0-9_\-\.]/g, '_');
|
|
103
94
|
const list = loadWorkspaces();
|
|
104
|
-
|
|
95
|
+
// Windows NTFS 不分大小写——`C:\App` 跟 `c:\app` 是同目录但 `===` 视为不同。
|
|
96
|
+
// 仅 Win 下小写化比较;POSIX 保持原样不引入回归。
|
|
97
|
+
const pathEq = (a, b) => process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
98
|
+
const existing = list.find(w => pathEq(w.path, resolvedPath));
|
|
105
99
|
if (existing) {
|
|
106
100
|
existing.lastUsed = new Date().toISOString();
|
|
107
101
|
existing.projectName = projectName;
|