@leiyi-works/dsh-session-tmpdir 0.9.7 → 0.9.8

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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/index.js +16 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -224,4 +224,6 @@ v0.9.5 变更(2026-11-16):**复制/移动类命令不再判源路径**。`
224
224
 
225
225
  v0.9.6 变更(2026-11-16):**`Start-Process` 不再默认算写命令**。它只是启动外部程序,参数里的路径通常是程序要打开的文件(读)。现在只有带 `-RedirectStandardOutput` / `-RedirectStandardError`(真正写文件)时才参与路径判定;`Start-Process notepad C:\缺失.txt` 这类不再误拦。
226
226
 
227
- v0.9.7 变更(2026-11-16):**白名单按机器分文件,修复跨机同步互相清空的问题**。此前白名单固定存 `~\.dsh\data\session-tmpdir-approvals.json`,该文件随云端同步:A 机批准的路径 B 机没有 → B 机刷新面板时按"目标不存在"回收条目 → 删减随同步回传,把 A 机的批准也删掉。现在每台机器用自己的文件 `session-tmpdir-approvals-<机器名>.json`(机器名取 `os.hostname()` 并做文件名安全化),互不覆盖;旧的无机器名文件只作为**只读迁移来源**(新文件不存在时读取一次,之后写入本机文件)。
227
+ v0.9.7 变更(2026-11-16):白名单曾改为按机器名分文件(`session-tmpdir-approvals-<机器名>.json`),意图是避免跨机同步互相覆盖。**该前提判断有误**,见 0.9.8。
228
+
229
+ v0.9.8 变更(2026-11-16):**白名单恢复通用文件名**。核对云端同步源码(`sync.js`:`data/session-tmpdir-*` 直接跳过)后确认:白名单文件本来就**不参与云端同步**,因此不会跨机覆盖、也不会每台机器多出别的机器的文件。改回固定路径 `<DSH_HOME>/data/session-tmpdir-approvals.json`(每台机器只有这一个文件);0.9.7 的按机器名文件只作为**读取回退**,写入统一回到通用文件。白名单语义:本机有效、同机重启后保留、跨机不共享(本来也不同步)。
package/index.js CHANGED
@@ -1306,32 +1306,34 @@ export function resolveDshHome() { const fromEnv = process.env.DSH_HOME && proc
1306
1306
  const APPROVALS_FILE = 'session-tmpdir-approvals.json'
1307
1307
 
1308
1308
  /**
1309
- * v0.9.7: 白名单按机器分文件,避免云端同步把别的机器的条目带过来后又因"目标不存在"被回收,
1310
- * 进而通过同步回传把原机器的批准也删掉(两台机互相清空)。
1309
+ * 白名单是本机文件:云端同步的排除名单包含 `data/session-tmpdir-*`
1310
+ * (cloud-sync: `rel.slice(5).startsWith('session-tmpdir-')` 直接跳过),
1311
+ * 因此固定用通用文件名即可,不会跨机同步、不会按机器产生多份文件。
1311
1312
  */
1312
- function approvalsFileSuffix() {
1313
+ function machineApprovalsPathV097() {
1313
1314
  let raw = ''
1314
1315
  try {
1315
1316
  raw = String(hostname() ?? '')
1316
1317
  } catch {
1317
1318
  raw = ''
1318
1319
  }
1319
- const safe = raw
1320
- .toLowerCase()
1321
- .replace(/[^a-z0-9._-]+/g, '-')
1322
- .replace(/^-+|-+$/g, '')
1323
- .slice(0, 40)
1324
- return safe || 'machine'
1320
+ const safe =
1321
+ raw
1322
+ .toLowerCase()
1323
+ .replace(/[^a-z0-9._-]+/g, '-')
1324
+ .replace(/^-+|-+$/g, '')
1325
+ .slice(0, 40) || 'machine'
1326
+ return join(resolveDshHome(), 'data', `session-tmpdir-approvals-${safe}.json`)
1325
1327
  }
1326
1328
 
1327
- /** Absolute path of this machine's whitelist store (`<DSH_HOME>/data/session-tmpdir-approvals-<machine>.json`). */
1329
+ /** Absolute path of the whitelist store (machine-local; never cloud-synced). */
1328
1330
  export function approvalsFilePath() {
1329
- return join(resolveDshHome(), 'data', `session-tmpdir-approvals-${approvalsFileSuffix()}.json`)
1331
+ return join(resolveDshHome(), 'data', APPROVALS_FILE)
1330
1332
  }
1331
1333
 
1332
- /** Pre-0.9.7 machine-agnostic filename: read fallback only, never written. */
1334
+ /** v0.9.8: 0.9.7 曾按机器名分文件;仅作读取回退,写入统一回到通用文件。 */
1333
1335
  export function legacyApprovalsFilePath() {
1334
- return join(resolveDshHome(), 'data', APPROVALS_FILE)
1336
+ return machineApprovalsPathV097()
1335
1337
  }
1336
1338
 
1337
1339
  /** Load the whitelist; a missing or corrupt file means an empty whitelist. */
@@ -2224,7 +2226,7 @@ export function apply(ctx, config) {
2224
2226
  '',
2225
2227
  '### Whitelist panel',
2226
2228
  '',
2227
- `Every approval is stored in this machine's own file \`<DSH_HOME>/data/session-tmpdir-approvals-<machine>.json\` (one file per machine, so cloud sync can never overwrite another machine's approvals) and shown in the left sidebar panel 「临时目录」 (display + remove only). Approvals survive a restart of the same session; entries whose session was deleted are pruned by the cleanup tick, and entries whose target no longer exists are pruned when the panel refreshes.`,
2229
+ `Every approval is stored in the machine-local file \`<DSH_HOME>/data/session-tmpdir-approvals.json\` (files under \`data/session-tmpdir-*\` are excluded from cloud sync, so nothing is shared across machines) and shown in the left sidebar panel 「临时目录」 (display + remove only). Approvals survive a restart of the same session; entries whose session was deleted are pruned by the cleanup tick, and entries whose target no longer exists are pruned when the panel refreshes.`,
2228
2230
  ].join('\n'),
2229
2231
  }),
2230
2232
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-session-tmpdir",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "type": "module",
5
5
  "description": "Per-session task temp folder with a long-term write guard. v0.9 (方案3): creating a new file outside _tmp requires the user's approval (per file by default, per directory with mode=dir), overwriting an existing file is allowed without asking, every write channel is guarded (write/edit, shell including ffmpeg/pandoc/Export-*/IO APIs, publish copies, code runtimes, unknown tools), and the persisted whitelist is shown in a left-sidebar panel「临时目录」 where entries can be removed. Every session also gets _tmp/<session title>/ in its working directory, cleaned 7 days after the session is deleted; the same tick reclaims the attachment store.",
6
6
  "exports": {