@cccarv82/freya 3.8.0 → 3.8.2
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/retroactive-ingest.js +10 -8
- package/cli/web.js +10 -11
- package/package.json +1 -1
- package/scripts/lib/DataLayer.js +28 -6
- package/templates/base/scripts/lib/DataLayer.js +28 -6
|
@@ -34,14 +34,16 @@ function run(cmd, args, cwd, extraEnv) {
|
|
|
34
34
|
const env = extraEnv ? { ...process.env, ...extraEnv } : process.env;
|
|
35
35
|
try {
|
|
36
36
|
if (process.platform === 'win32') {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
// If we have a full path to the executable, use it directly with spawn
|
|
38
|
+
// (no shell needed — avoids PowerShell argument mangling).
|
|
39
|
+
// Only fall back to cmd.exe for bare command names.
|
|
40
|
+
if (path.isAbsolute(cmd) || cmd.includes('\\') || cmd.includes('/')) {
|
|
41
|
+
child = spawn(cmd, args, { cwd, env, windowsHide: true });
|
|
42
|
+
} else {
|
|
43
|
+
// Bare command name — use cmd.exe to resolve from PATH
|
|
44
|
+
const comspec = process.env.ComSpec || 'cmd.exe';
|
|
45
|
+
child = spawn(comspec, ['/d', '/s', '/c', cmd, ...args], { cwd, shell: false, env });
|
|
46
|
+
}
|
|
45
47
|
} else {
|
|
46
48
|
child = spawn(cmd, args, { cwd, shell: true, env });
|
|
47
49
|
}
|
package/cli/web.js
CHANGED
|
@@ -971,17 +971,16 @@ function run(cmd, args, cwd, extraEnv, stdinData) {
|
|
|
971
971
|
|
|
972
972
|
try {
|
|
973
973
|
if (process.platform === 'win32') {
|
|
974
|
-
//
|
|
975
|
-
//
|
|
976
|
-
//
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
], { cwd, env, windowsHide: true });
|
|
974
|
+
// getCopilotCmd() resolves the full path via PowerShell/where.
|
|
975
|
+
// Once we have the full path, spawn directly — no shell needed.
|
|
976
|
+
// This avoids PowerShell argument mangling issues.
|
|
977
|
+
if (path.isAbsolute(cmd) || cmd.includes('\\') || cmd.includes('/')) {
|
|
978
|
+
child = spawn(cmd, args, { cwd, env, windowsHide: true });
|
|
979
|
+
} else {
|
|
980
|
+
// Bare command name — use cmd.exe to resolve from PATH
|
|
981
|
+
const comspec = process.env.ComSpec || 'cmd.exe';
|
|
982
|
+
child = spawn(comspec, ['/d', '/s', '/c', cmd, ...args], { cwd, shell: false, env });
|
|
983
|
+
}
|
|
985
984
|
} else {
|
|
986
985
|
child = spawn(cmd, args, { cwd, shell: true, env });
|
|
987
986
|
}
|
package/package.json
CHANGED
package/scripts/lib/DataLayer.js
CHANGED
|
@@ -100,15 +100,37 @@ class SqlJsDatabase {
|
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Persist the in-memory database to disk.
|
|
103
|
+
* Retries with backoff on EBUSY (OneDrive/cloud sync locking).
|
|
103
104
|
*/
|
|
104
105
|
_save() {
|
|
105
106
|
if (!this._filePath) return;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const data = this._db.export();
|
|
108
|
+
const buffer = Buffer.from(data);
|
|
109
|
+
const maxRetries = 5;
|
|
110
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
111
|
+
try {
|
|
112
|
+
// Write to temp file + rename for atomic operation
|
|
113
|
+
const tmpPath = this._filePath + '.tmp';
|
|
114
|
+
fs.writeFileSync(tmpPath, buffer);
|
|
115
|
+
try {
|
|
116
|
+
fs.renameSync(tmpPath, this._filePath);
|
|
117
|
+
} catch (renameErr) {
|
|
118
|
+
// On Windows, rename can fail if target is locked; fall back to direct write
|
|
119
|
+
try { fs.unlinkSync(tmpPath); } catch { }
|
|
120
|
+
fs.writeFileSync(this._filePath, buffer);
|
|
121
|
+
}
|
|
122
|
+
return; // success
|
|
123
|
+
} catch (err) {
|
|
124
|
+
if ((err.code === 'EBUSY' || err.code === 'EPERM') && attempt < maxRetries) {
|
|
125
|
+
// Wait with exponential backoff: 100ms, 200ms, 400ms, 800ms, 1600ms
|
|
126
|
+
const delay = 100 * Math.pow(2, attempt);
|
|
127
|
+
const start = Date.now();
|
|
128
|
+
while (Date.now() - start < delay) { /* busy wait — sync context */ }
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
console.error('[DataLayer] Failed to save database:', err.message);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
112
134
|
}
|
|
113
135
|
}
|
|
114
136
|
|
|
@@ -100,15 +100,37 @@ class SqlJsDatabase {
|
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Persist the in-memory database to disk.
|
|
103
|
+
* Retries with backoff on EBUSY (OneDrive/cloud sync locking).
|
|
103
104
|
*/
|
|
104
105
|
_save() {
|
|
105
106
|
if (!this._filePath) return;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const data = this._db.export();
|
|
108
|
+
const buffer = Buffer.from(data);
|
|
109
|
+
const maxRetries = 5;
|
|
110
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
111
|
+
try {
|
|
112
|
+
// Write to temp file + rename for atomic operation
|
|
113
|
+
const tmpPath = this._filePath + '.tmp';
|
|
114
|
+
fs.writeFileSync(tmpPath, buffer);
|
|
115
|
+
try {
|
|
116
|
+
fs.renameSync(tmpPath, this._filePath);
|
|
117
|
+
} catch (renameErr) {
|
|
118
|
+
// On Windows, rename can fail if target is locked; fall back to direct write
|
|
119
|
+
try { fs.unlinkSync(tmpPath); } catch { }
|
|
120
|
+
fs.writeFileSync(this._filePath, buffer);
|
|
121
|
+
}
|
|
122
|
+
return; // success
|
|
123
|
+
} catch (err) {
|
|
124
|
+
if ((err.code === 'EBUSY' || err.code === 'EPERM') && attempt < maxRetries) {
|
|
125
|
+
// Wait with exponential backoff: 100ms, 200ms, 400ms, 800ms, 1600ms
|
|
126
|
+
const delay = 100 * Math.pow(2, attempt);
|
|
127
|
+
const start = Date.now();
|
|
128
|
+
while (Date.now() - start < delay) { /* busy wait — sync context */ }
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
console.error('[DataLayer] Failed to save database:', err.message);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
112
134
|
}
|
|
113
135
|
}
|
|
114
136
|
|