gm-thebird 2.0.1014 → 2.0.1015
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/bin/bootstrap.js +34 -2
- package/gm.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
package/bin/bootstrap.js
CHANGED
|
@@ -169,11 +169,43 @@ function copyToGmTools(finalPath, wrapperDir, version) {
|
|
|
169
169
|
const target = path.join(dst, exeName);
|
|
170
170
|
const targetTmp = target + '.new';
|
|
171
171
|
cleanOrphanNewFiles(dst, exeName);
|
|
172
|
+
if (fs.existsSync(target)) {
|
|
173
|
+
let needsRefresh = true;
|
|
174
|
+
try {
|
|
175
|
+
const cur = sha256OfFileSync(target);
|
|
176
|
+
const src = sha256OfFileSync(finalPath);
|
|
177
|
+
if (cur === src) needsRefresh = false;
|
|
178
|
+
} catch (_) {}
|
|
179
|
+
if (!needsRefresh) {
|
|
180
|
+
try { fs.writeFileSync(path.join(dst, 'plugkit.version'), version); } catch (_) {}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
try { killHoldersOfPath(target); } catch (_) {}
|
|
184
|
+
}
|
|
172
185
|
fs.copyFileSync(finalPath, targetTmp);
|
|
173
186
|
if (!renameWithRetry(targetTmp, target, 8)) {
|
|
174
|
-
|
|
175
|
-
|
|
187
|
+
try { killHoldersOfPath(target); } catch (_) {}
|
|
188
|
+
try { fs.unlinkSync(target); } catch (_) {}
|
|
189
|
+
try { fs.renameSync(targetTmp, target); }
|
|
190
|
+
catch (_) {
|
|
191
|
+
try { fs.unlinkSync(targetTmp); } catch (_) {}
|
|
192
|
+
obsEvent('bootstrap', 'gmtools.rename.failed', { target });
|
|
193
|
+
writeBootstrapError({
|
|
194
|
+
expected_version: version,
|
|
195
|
+
cached_version: null,
|
|
196
|
+
error_phase: 'gmtools-rename',
|
|
197
|
+
error_message: `cannot replace ${target} after kill+unlink retry; orphan removed`,
|
|
198
|
+
});
|
|
199
|
+
throw new Error(`gm-tools update blocked: cannot replace ${target} (held open by running plugkit and kill-retry exhausted)`);
|
|
200
|
+
}
|
|
176
201
|
}
|
|
202
|
+
try {
|
|
203
|
+
for (const name of fs.readdirSync(dst)) {
|
|
204
|
+
if (/^plugkit(\.\d+\.\d+\.\d+)?\.new$/i.test(name)) {
|
|
205
|
+
try { fs.unlinkSync(path.join(dst, name)); } catch (_) {}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} catch (_) {}
|
|
177
209
|
if (process.platform !== 'win32') {
|
|
178
210
|
try { fs.chmodSync(target, 0o755); } catch (_) {}
|
|
179
211
|
}
|
package/gm.json
CHANGED
package/package.json
CHANGED