mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: move code out of try {} block
Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user