dsh-sweeper 1.5.3 → 1.5.4

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/README.md CHANGED
@@ -273,6 +273,7 @@ node test/browser/check.mjs # 需要本机有 Chrome/Edge,或 CHROME=<p
273
273
 
274
274
  ## 边界与自保
275
275
 
276
+ - **动不了文件时说得清楚**:权限、占用、磁盘满这类系统错误会翻成一句话(`MOVE_ERRORS`),不再把 `EPERM` 直接丢到页面上;未列出的代码也会写成「系统拒绝了这次操作(CODE)」。
276
277
  - **重新扫描不会打断正在跑的深度分析**:报告换了,但运行中的那一轮继续,页面继续轮询;结果里的每个路径在移动前都会对磁盘重新校验。
277
278
  - **模型读报告期间如果你重扫了**,这一轮复核会被丢弃并返回 409,什么都不移动——判定针对的是你刚才看的那份报告。
278
279
  - **读不出来的会话日志**只让那一段从计划里消失,不会让整份计划失败;页面会写「N 段日志读不出来」。
package/lib/client.js CHANGED
@@ -127,6 +127,12 @@ window.__ModuleLoader__.load({
127
127
  [/batch is busy/i, '这个批次正在被恢复或删除,稍等一下'],
128
128
  [/bad batch id/i, '批次号不合法'],
129
129
  [/already gone/i, '这一批已经被删掉了(可能是另一个标签页刚删的)'],
130
+ [/the folder for that file is gone/i, '原来的文件夹已经不在了,文件还在回收站里'],
131
+ [/permission denied while moving the file/i, '系统不让动这个文件(可能被程序占用,或被安全软件拦住)'],
132
+ [/the file is still open by another program/i, '还有程序在用这个文件,关掉它再试'],
133
+ [/^the disk is full$/i, '磁盘空间不够了,没法把它写回去'],
134
+ [/something else is now at that path/i, '原来的位置现在被别的东西占着'],
135
+ [/the path is too long for this file system/i, '路径太长,这个磁盘不认'],
130
136
  [/still open by another program/i, '批次里有文件正被别的程序占用,关掉占用它的程序再试'],
131
137
  [/no files were moved/i, '这次没有移动任何文件'],
132
138
  [/a file already exists there/i, '原位置已经有同名文件,没有覆盖'],
@@ -192,6 +198,7 @@ window.__ModuleLoader__.load({
192
198
  if (hit) return head + (typeof hit[1] === 'function' ? hit[1](body.match(hit[0])) : hit[1])
193
199
  if (/^HTTP \d+$/.test(body)) return head + '服务返回 ' + body.slice(5) + ',请重试'
194
200
  if (/failed to fetch|networkerror|load failed/i.test(body)) return head + '连不上插件服务,DSH 可能刚重启'
201
+ if (/^[A-Z][A-Z0-9_]{2,}$/.test(body)) return head + '系统拒绝了这次操作(' + body + ')'
195
202
  return raw
196
203
  }
197
204
  const humanError = (err) => humanReason((err && err.message) || err)
package/lib/trash.js CHANGED
@@ -14,6 +14,23 @@ import { homedir } from 'node:os'
14
14
 
15
15
  export const MAX_BATCH = 5000
16
16
 
17
+ /**
18
+ * The errno values a move realistically fails with, spelled out. A bare code
19
+ * used to reach the page as 恢复失败:EPERM; the client translates sentences.
20
+ */
21
+ export const MOVE_ERRORS = {
22
+ ENOENT: 'the folder for that file is gone',
23
+ EACCES: 'permission denied while moving the file',
24
+ EPERM: 'permission denied while moving the file',
25
+ EBUSY: 'the file is still open by another program',
26
+ ENOSPC: 'the disk is full',
27
+ EISDIR: 'something else is now at that path',
28
+ ENOTDIR: 'something else is now at that path',
29
+ ENAMETOOLONG: 'the path is too long for this file system',
30
+ }
31
+
32
+ export const moveReason = (err) => (err && MOVE_ERRORS[err.code]) || (err && err.code) || String(err)
33
+
17
34
  export function dshHome() {
18
35
  const env = process.env.DSH_HOME
19
36
  if (env && env.trim()) return resolve(env.trim())
@@ -185,7 +202,7 @@ export async function quarantine(items, meta = {}) {
185
202
  try {
186
203
  await moveFile(item.path, dest)
187
204
  } catch (err) {
188
- failed.push({ path: item.path, reason: (err && err.code) || String(err) })
205
+ failed.push({ path: item.path, reason: moveReason(err) })
189
206
  continue
190
207
  }
191
208
 
@@ -278,7 +295,7 @@ export async function restore(id) {
278
295
  await moveFile(src, entry.orig)
279
296
  restored.push(entry.orig)
280
297
  } catch (err) {
281
- failed.push({ path: entry.orig, reason: (err && err.code) || String(err) })
298
+ failed.push({ path: entry.orig, reason: moveReason(err) })
282
299
  keep.push(entry)
283
300
  }
284
301
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sweeper",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "type": "module",
5
5
  "description": "清理对话留下的临时文件与垃圾,释放磁盘空间;只报告,清理进回收站可恢复 (cleanup junk files conversations leave on disk, free up space)",
6
6
  "keywords": [