refactor: move code out of try {} block

Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
izzy
2026-02-06 17:32:32 +00:00
parent bbcb6b8247
commit 6c38417ebd
+8 -8
View File
@@ -497,9 +497,9 @@ export class IntegrityService extends BaseService {
for await (const { originalPath, checksum, createdAt, assetId, reportId } of assets) { for await (const { originalPath, checksum, createdAt, assetId, reportId } of assets) {
processed++; processed++;
try { const hash = createHash('sha1');
const hash = createHash('sha1');
try {
await pipeline([ await pipeline([
this.storageRepository.createPlainReadStream(originalPath), this.storageRepository.createPlainReadStream(originalPath),
new Writable({ new Writable({
@@ -571,9 +571,9 @@ export class IntegrityService extends BaseService {
return reportId; return reportId;
} }
try { const hash = createHash('sha1');
const hash = createHash('sha1');
try {
await pipeline([ await pipeline([
this.storageRepository.createPlainReadStream(path), this.storageRepository.createPlainReadStream(path),
new Writable({ new Writable({
@@ -583,15 +583,15 @@ export class IntegrityService extends BaseService {
}, },
}), }),
]); ]);
if (Buffer.from(checksum, 'hex').equals(hash.digest())) {
return reportId;
}
} catch (error) { } catch (error) {
if ((error as { code?: string }).code === 'ENOENT') { if ((error as { code?: string }).code === 'ENOENT') {
return reportId; return reportId;
} }
} }
if (Buffer.from(checksum, 'hex').equals(hash.digest())) {
return reportId;
}
}), }),
); );