pinokiod 8.0.65 → 8.0.67

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/index.js CHANGED
@@ -1062,6 +1062,19 @@ class Kernel {
1062
1062
  kill() {
1063
1063
  process.kill(process.pid, "SIGTERM")
1064
1064
  }
1065
+ async disposeVaultAutomaticScans() {
1066
+ const vault = this.vault
1067
+ if (!vault || !vault.automaticScans) return false
1068
+ if (vault.ready) await Promise.resolve(vault.ready).catch(() => {})
1069
+ try {
1070
+ await vault.automaticScans.dispose()
1071
+ return true
1072
+ } catch (error) {
1073
+ console.warn("Vault automatic cleanup error:",
1074
+ error && error.message ? error.message : error)
1075
+ return false
1076
+ }
1077
+ }
1065
1078
  /// async fileserver() {
1066
1079
  /// await this.exec({
1067
1080
  /// message: `npx -y filexplorer --serveDirectory ${this.homedir}`
@@ -1079,6 +1092,8 @@ class Kernel {
1079
1092
  })
1080
1093
 
1081
1094
  let home = this.store.get("home") || process.env.PINOKIO_HOME
1095
+ await this.disposeVaultAutomaticScans()
1096
+ this.vault = null
1082
1097
  this.homedir = home
1083
1098
 
1084
1099
  // reset shells if they exist
@@ -1247,12 +1262,20 @@ class Kernel {
1247
1262
  await this.git.loadCheckpoints()
1248
1263
  console.timeEnd("git.loadCheckpoints")
1249
1264
 
1250
- // Shared model store: startup reads only the enable flag. Registry and
1251
- // filesystem initialization are deferred until a Vault page or action
1252
- // calls ensureInitialized().
1253
- this.vault = new Vault(this)
1265
+ // Disk Saver startup reads the enable flag and, where supported, starts
1266
+ // its native API-directory watcher. Registry and scan initialization
1267
+ // remain deferred until a Disk Saver page or action needs them.
1268
+ const vault = new Vault(this)
1269
+ this.vault = vault
1254
1270
  if (this.homedir) {
1255
- this.vault.ready = this.vault.init({ deferStorage: true }).catch((err) => {
1271
+ vault.ready = vault.init({ deferStorage: true }).then(
1272
+ async (result) => {
1273
+ if (result && result.enabled) {
1274
+ await vault.automaticScans.startWatcher()
1275
+ }
1276
+ return result
1277
+ }
1278
+ ).catch((err) => {
1256
1279
  // Keep an enabled Vault retryable after transient registry or
1257
1280
  // filesystem errors. A genuinely disabled Vault already has
1258
1281
  // enabled=false from its environment check.