pinokiod 8.0.108 → 8.0.110
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/kernel/vault/index.js +3 -38
- package/package.json +1 -1
- package/test/vault-engine.test.js +23 -0
package/kernel/vault/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const fs = require("fs")
|
|
2
2
|
const path = require("path")
|
|
3
3
|
const crypto = require("crypto")
|
|
4
|
-
const { execFile } = require("child_process")
|
|
5
4
|
const { Worker } = require("worker_threads")
|
|
5
|
+
const Util = require("../util")
|
|
6
6
|
const Registry = require("./registry")
|
|
7
7
|
const Scanner = require("./scanner")
|
|
8
8
|
const Sweeper = require("./sweeper")
|
|
@@ -188,41 +188,11 @@ class FileActionChanges {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
const revealInFileManager = (filePath, platform = process.platform) =>
|
|
192
|
-
new Promise((resolve, reject) => {
|
|
193
|
-
const command = platform === "darwin"
|
|
194
|
-
? "open"
|
|
195
|
-
: platform === "win32"
|
|
196
|
-
? "explorer.exe"
|
|
197
|
-
: "xdg-open"
|
|
198
|
-
const args = platform === "darwin"
|
|
199
|
-
? ["-R", filePath]
|
|
200
|
-
: platform === "win32"
|
|
201
|
-
? [`/select,${filePath}`]
|
|
202
|
-
: [path.dirname(filePath)]
|
|
203
|
-
execFile(command, args, {
|
|
204
|
-
timeout: 10000,
|
|
205
|
-
windowsHide: true
|
|
206
|
-
}, (error) => {
|
|
207
|
-
// Explorer reports a non-zero exit code even when it opens the folder,
|
|
208
|
-
// so an exit status alone is not a failure on Windows. A missing binary
|
|
209
|
-
// or a refused spawn still is.
|
|
210
|
-
if (error && platform === "win32" && Number.isInteger(error.code)) {
|
|
211
|
-
resolve()
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
error ? reject(error) : resolve()
|
|
215
|
-
})
|
|
216
|
-
})
|
|
217
|
-
|
|
218
191
|
class Vault {
|
|
219
192
|
constructor(kernel) {
|
|
220
193
|
this.kernel = kernel
|
|
221
194
|
this.fileManagerLauncher = (filePath) =>
|
|
222
|
-
|
|
223
|
-
filePath,
|
|
224
|
-
this.kernel.platform || process.platform
|
|
225
|
-
)
|
|
195
|
+
Util.openfs(filePath, { action: "view" }, this.kernel)
|
|
226
196
|
this.enabled = false
|
|
227
197
|
this.initialized = false
|
|
228
198
|
this.mode = null
|
|
@@ -3320,18 +3290,13 @@ class Vault {
|
|
|
3320
3290
|
}
|
|
3321
3291
|
|
|
3322
3292
|
publicDuplicateChildItems(rows) {
|
|
3323
|
-
const publicStatus = {
|
|
3324
|
-
reference: "tracked",
|
|
3325
|
-
duplicate: "duplicate",
|
|
3326
|
-
linked: "shared"
|
|
3327
|
-
}
|
|
3328
3293
|
return (rows || []).map((row) => Object.assign({
|
|
3329
3294
|
kind: "duplicate_path",
|
|
3330
3295
|
path: row.path,
|
|
3331
3296
|
hash: row.hash,
|
|
3332
3297
|
size: Number(row.size) || 0,
|
|
3333
3298
|
app: row.app || null,
|
|
3334
|
-
status:
|
|
3299
|
+
status: PUBLIC_FILE_STATUS[row.status],
|
|
3335
3300
|
registry_status: row.status,
|
|
3336
3301
|
shareable: row.status === "duplicate",
|
|
3337
3302
|
selectable: !!row.selectable
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require("node:fs")
|
|
|
5
5
|
const os = require("node:os")
|
|
6
6
|
const path = require("node:path")
|
|
7
7
|
const Database = require("better-sqlite3")
|
|
8
|
+
const Util = require("../kernel/util")
|
|
8
9
|
const Vault = require("../kernel/vault")
|
|
9
10
|
const Registry = require("../kernel/vault/registry")
|
|
10
11
|
const {
|
|
@@ -105,6 +106,28 @@ describe("Save Space engine", () => {
|
|
|
105
106
|
}
|
|
106
107
|
})
|
|
107
108
|
|
|
109
|
+
test("file reveals reuse the shared file explorer launcher", async () => {
|
|
110
|
+
const kernel = { homedir: os.tmpdir(), platform: process.platform }
|
|
111
|
+
const vault = new Vault(kernel)
|
|
112
|
+
const originalOpenfs = Util.openfs
|
|
113
|
+
const calls = []
|
|
114
|
+
Util.openfs = (...args) => {
|
|
115
|
+
calls.push(args)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const filePath = path.join(os.tmpdir(), "model with spaces.bin")
|
|
120
|
+
await vault.fileManagerLauncher(filePath)
|
|
121
|
+
assert.deepEqual(calls, [[
|
|
122
|
+
filePath,
|
|
123
|
+
{ action: "view" },
|
|
124
|
+
kernel
|
|
125
|
+
]])
|
|
126
|
+
} finally {
|
|
127
|
+
Util.openfs = originalOpenfs
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
|
|
108
131
|
test("startup only reads the enable flag and defers Disk Saver storage", async () => {
|
|
109
132
|
const home = await makeHome()
|
|
110
133
|
const vault = new Vault({ homedir: home, platform: process.platform })
|