mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-05-21 07:22:44 +00:00
build: compile dist/ [auto]
This commit is contained in:
19
dist/usage-api.js
vendored
19
dist/usage-api.js
vendored
@@ -127,6 +127,25 @@ function tryAcquireCacheLock(homeDir) {
|
||||
}
|
||||
}
|
||||
const lockTimestamp = readLockTimestamp(lockPath);
|
||||
// Unparseable timestamp — use mtime to distinguish a crash leftover from an active writer.
|
||||
if (lockTimestamp === null) {
|
||||
try {
|
||||
const lockStat = fs.statSync(lockPath);
|
||||
if (Date.now() - lockStat.mtimeMs < CACHE_LOCK_STALE_MS) {
|
||||
return 'busy';
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return tryAcquireCacheLock(homeDir);
|
||||
}
|
||||
try {
|
||||
fs.unlinkSync(lockPath);
|
||||
}
|
||||
catch {
|
||||
return 'busy';
|
||||
}
|
||||
return tryAcquireCacheLock(homeDir);
|
||||
}
|
||||
if (lockTimestamp != null && Date.now() - lockTimestamp > CACHE_LOCK_STALE_MS) {
|
||||
try {
|
||||
fs.unlinkSync(lockPath);
|
||||
|
||||
Reference in New Issue
Block a user