Skip to content

Commit

Permalink
feat: improve stac-validate logs TDE-1385
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfouquet committed Feb 3, 2025
1 parent e2d75d7 commit b2c764e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/commands/stac-validate/stac.validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,24 +308,27 @@ export async function validateStacChecksum(

if (checksum == null) {
if (allowMissing) return true;
logger.error({ source, checksum }, 'Validate:Checksum:Missing');
logger.error({ source, checksum, type: stacObject.rel, parent: path }, 'Validate:Checksum:Missing');
return false;
}

if (!checksum.startsWith(Sha256Prefix)) {
logger.error({ source, checksum }, 'Validate:Checksum:Unknown');
logger.error({ source, checksum, type: stacObject.rel, parent: path }, 'Validate:Checksum:Unknown');
return false;
}
logger.debug({ source, checksum }, 'Validate:Checksum');
const startTime = performance.now();
const hash = await hashStream(fsa.stream(source));
const duration = performance.now() - startTime;

stacObject.rel;
if (hash !== checksum) {
logger.error({ source, checksum, found: hash, duration }, 'Checksum:Validation:Failed');
logger.error(
{ source, checksum, found: hash, type: stacObject.rel, parent: path, duration },
'Checksum:Validation:Failed',
);
return false;
}
logger.debug({ source, checksum, duration }, 'Checksum:Validation:Ok');
logger.debug({ source, checksum, type: stacObject.rel, parent: path, duration }, 'Checksum:Validation:Ok');
return true;
}

Expand Down

0 comments on commit b2c764e

Please sign in to comment.