paratix 0.12.2 → 0.12.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.
|
@@ -1268,19 +1268,32 @@ async function writeFlagLockHolderMarker(ssh2, lockName) {
|
|
|
1268
1268
|
kind: "failed"
|
|
1269
1269
|
};
|
|
1270
1270
|
}
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1271
|
+
const readbackResult = await ssh2.exec(`awk 'NR==1{print $1}' ${quotedMarker}`, { ignoreExitCode: true, silent: true }).catch(() => null);
|
|
1272
|
+
const holderToken = readbackResult?.stdout.trim() ?? "";
|
|
1273
|
+
if (readbackResult?.code !== 0 || holderToken.length === 0) {
|
|
1273
1274
|
await ssh2.exec(`rm -f -- ${markerPath2}`, { ignoreExitCode: true, silent: true });
|
|
1274
1275
|
await ssh2.exec(`rmdir -- ${lock}`, { ignoreExitCode: true, silent: true });
|
|
1275
1276
|
return {
|
|
1276
|
-
failure:
|
|
1277
|
-
`[moduleHelpers] flag lock holder marker for ${lockName} is empty after write`
|
|
1278
|
-
),
|
|
1277
|
+
failure: buildReadbackFailure(lockName, readbackResult),
|
|
1279
1278
|
kind: "failed"
|
|
1280
1279
|
};
|
|
1281
1280
|
}
|
|
1282
1281
|
return { holderToken, kind: "ok" };
|
|
1283
1282
|
}
|
|
1283
|
+
function buildReadbackFailure(lockName, readbackResult) {
|
|
1284
|
+
if (readbackResult == null) {
|
|
1285
|
+
return failed(
|
|
1286
|
+
`[moduleHelpers] flag lock holder marker for ${lockName} readback failed: ssh.exec threw before returning a result`
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1289
|
+
if (readbackResult.code !== 0) {
|
|
1290
|
+
return failedCommand(
|
|
1291
|
+
`[moduleHelpers] flag lock holder marker for ${lockName} readback failed`,
|
|
1292
|
+
readbackResult
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
return failed(`[moduleHelpers] flag lock holder marker for ${lockName} is readable but empty`);
|
|
1296
|
+
}
|
|
1284
1297
|
async function acquireFlagLock(ssh2, lockName) {
|
|
1285
1298
|
validateFlagName(lockName, "lockName");
|
|
1286
1299
|
const ensureFailure = await ensureFlagsDirectory(ssh2);
|
|
@@ -1305,7 +1318,7 @@ async function releaseFlagLock(ssh2, lockName, holderToken) {
|
|
|
1305
1318
|
const markerPath2 = `${lock}/${HOLDER_MARKER_NAME}`;
|
|
1306
1319
|
const quotedMarker = shellQuote(`${flagLockDisplayPath(lockName)}/${HOLDER_MARKER_NAME}`);
|
|
1307
1320
|
const expectedToken = `x${holderToken}`;
|
|
1308
|
-
const command2 = `awk_token=$(awk 'NR==1{print $1}'
|
|
1321
|
+
const command2 = `awk_token=$(awk 'NR==1{print $1}' ${quotedMarker} 2>/dev/null); awk_status=$?; [ "$awk_status" = 0 ] && [ "x$awk_token" = ${shellQuote(expectedToken)} ] && rm -f -- ${markerPath2} && rmdir -- ${lock}`;
|
|
1309
1322
|
await ssh2.exec(command2, { ignoreExitCode: true, silent: true });
|
|
1310
1323
|
}
|
|
1311
1324
|
async function tryReclaimStaleFlagLock(ssh2, lockName, staleSeconds) {
|
|
@@ -1314,7 +1327,7 @@ async function tryReclaimStaleFlagLock(ssh2, lockName, staleSeconds) {
|
|
|
1314
1327
|
const quotedMarker = shellQuote(`${flagLockDisplayPath(lockName)}/${HOLDER_MARKER_NAME}`);
|
|
1315
1328
|
const staleMinutes = Math.max(1, Math.ceil(staleSeconds / SECONDS_PER_MINUTE));
|
|
1316
1329
|
const mminThreshold = String(staleMinutes - 1);
|
|
1317
|
-
const command2 = `if [ -d ${lock} ]; then if [ -f ${markerPath2} ]; then STALE_TOKEN="$(awk 'NR==1{print $1}'
|
|
1330
|
+
const command2 = `if [ -d ${lock} ]; then if [ -f ${markerPath2} ]; then STALE_TOKEN="$(awk 'NR==1{print $1}' ${quotedMarker} 2>/dev/null)"; if find ${markerPath2} -maxdepth 0 -mmin +${mminThreshold} -print -quit | grep -q .; then [ "$(awk 'NR==1{print $1}' ${quotedMarker} 2>/dev/null)" = "$STALE_TOKEN" ] && rm -f -- ${markerPath2} && rmdir -- ${lock}; else exit 1; fi; else if find ${lock} -maxdepth 0 -mmin +${mminThreshold} -print -quit | grep -q .; then find ${lock} -maxdepth 0 -mmin +${mminThreshold} -print -quit | grep -q . && rm -f -- ${markerPath2} && rmdir -- ${lock}; else exit 1; fi; fi; else exit 1; fi`;
|
|
1318
1331
|
const result = await ssh2.exec(command2, { ignoreExitCode: true, silent: true });
|
|
1319
1332
|
return result.code === 0;
|
|
1320
1333
|
}
|
|
@@ -19055,4 +19068,4 @@ export {
|
|
|
19055
19068
|
ufw,
|
|
19056
19069
|
user
|
|
19057
19070
|
};
|
|
19058
|
-
//# sourceMappingURL=chunk-
|
|
19071
|
+
//# sourceMappingURL=chunk-QVU4YEKK.js.map
|