fix: release local heavy-check locks on success

This commit is contained in:
Tak Hoffman
2026-04-10 17:03:52 -05:00
parent 8b7ba0e481
commit f16a66fa43
5 changed files with 59 additions and 6 deletions

View File

@@ -133,6 +133,9 @@ export function acquireLocalHeavyCheckLockSync(params) {
let lastProgressAt = 0;
fs.mkdirSync(locksDir, { recursive: true });
if (!params.lockName) {
cleanupLegacyLockDirs(locksDir, staleLockMs);
}
for (;;) {
try {
@@ -210,6 +213,20 @@ export function resolveGitCommonDir(cwd) {
return path.join(cwd, ".git");
}
function cleanupLegacyLockDirs(locksDir, staleLockMs) {
for (const legacyLockName of ["test"]) {
const legacyLockDir = path.join(locksDir, `${legacyLockName}.lock`);
if (!fs.existsSync(legacyLockDir)) {
continue;
}
const owner = readOwnerFile(path.join(legacyLockDir, "owner.json"));
if (shouldReclaimLock({ owner, lockDir: legacyLockDir, staleLockMs })) {
fs.rmSync(legacyLockDir, { recursive: true, force: true });
}
}
}
function insertBeforeSeparator(args, ...items) {
if (items.length > 0 && hasFlag(args, items[0])) {
return;