mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
fix: widen hash lock try/finally to prevent lock leak on error paths
This commit is contained in:
@@ -1042,11 +1042,16 @@ async function processOneArchiveSet(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let entries: { path: string; fileName: string; extension: string | null; compressedSize: bigint; uncompressedSize: bigint; crc32: string | null }[] = [];
|
||||||
|
let creator: string | null = null;
|
||||||
|
const tags: string[] = [];
|
||||||
|
let stub: { id: string } | null = null;
|
||||||
|
|
||||||
|
try {
|
||||||
// Re-check after acquiring lock: another worker may have finished between
|
// Re-check after acquiring lock: another worker may have finished between
|
||||||
// the first check above and this point.
|
// the first check above and this point.
|
||||||
const existsAfterLock = await packageExistsByHash(contentHash);
|
const existsAfterLock = await packageExistsByHash(contentHash);
|
||||||
if (existsAfterLock) {
|
if (existsAfterLock) {
|
||||||
await releaseHashLock(contentHash);
|
|
||||||
counters.zipsDuplicate++;
|
counters.zipsDuplicate++;
|
||||||
accountLog.debug(
|
accountLog.debug(
|
||||||
{ fileName: archiveName, hash: contentHash.slice(0, 16) },
|
{ fileName: archiveName, hash: contentHash.slice(0, 16) },
|
||||||
@@ -1065,7 +1070,6 @@ async function processOneArchiveSet(
|
|||||||
totalFiles: totalSets,
|
totalFiles: totalSets,
|
||||||
});
|
});
|
||||||
|
|
||||||
let entries: { path: string; fileName: string; extension: string | null; compressedSize: bigint; uncompressedSize: bigint; crc32: string | null }[] = [];
|
|
||||||
try {
|
try {
|
||||||
if (archiveSet.type === "ZIP") {
|
if (archiveSet.type === "ZIP") {
|
||||||
entries = await readZipCentralDirectory(tempPaths);
|
entries = await readZipCentralDirectory(tempPaths);
|
||||||
@@ -1167,12 +1171,6 @@ async function processOneArchiveSet(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hoist creator/tags so they're visible after try block for logging
|
|
||||||
let creator: string | null = null;
|
|
||||||
const tags: string[] = [];
|
|
||||||
|
|
||||||
let stub: { id: string } | null = null;
|
|
||||||
try {
|
|
||||||
// ── Uploading ──
|
// ── Uploading ──
|
||||||
// Check if a prior run already uploaded this file (orphaned upload scenario:
|
// Check if a prior run already uploaded this file (orphaned upload scenario:
|
||||||
// file reached Telegram but DB write failed or worker crashed before indexing)
|
// file reached Telegram but DB write failed or worker crashed before indexing)
|
||||||
|
|||||||
Reference in New Issue
Block a user