lpm - usar revision id

This commit is contained in:
Cat /dev/Nulo 2024-09-02 11:32:46 -03:00
parent 5a79372cd8
commit e376be121a
2 changed files with 14 additions and 12 deletions

View file

@ -1,17 +1,19 @@
import { z } from "zod";
export const zDatasetInfo = z.object({
metadata_modified: z.coerce.date(),
metadata_created: z.coerce.date(),
resources: z.array(
z.object({
export const zResource = z.object({
id: z.string(),
revision_id: z.string(),
size: z.number(),
format: z.string(),
created: z.coerce.date(),
url: z.string(),
modified: z.coerce.date().optional(),
description: z.string(),
}),
),
});
export type Resource = z.infer<typeof zResource>;
export const zDatasetInfo = z.object({
metadata_modified: z.coerce.date(),
metadata_created: z.coerce.date(),
resources: z.array(zResource),
});
export type DatasetInfo = z.infer<typeof zDatasetInfo>;

View file

@ -122,7 +122,7 @@ await uploadToB2Bucket(
const datasetInfo = z.object({ result: zDatasetInfo }).parse(rawDatasetInfo);
for (const resource of datasetInfo.result.resources) {
if (extname(resource.url) === ".zip") {
const fileName = `${resource.id}-${basename(resource.url)}-repackaged.tar.zst`;
const fileName = `${resource.id}-revID-${resource.revision_id}-${basename(resource.url)}-repackaged.tar.zst`;
if (await checkFileExistsInB2(fileName)) continue;
console.log(`⬇️ Downloading, repackaging and uploading ${resource.url}`);
const dir = await mkdtemp("/tmp/sepa-precios-archiver-repackage-");