mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
lpm - usar revision id
This commit is contained in:
parent
5a79372cd8
commit
e376be121a
2 changed files with 14 additions and 12 deletions
|
@ -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>;
|
||||
|
|
|
@ -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-");
|
||||
|
|
Loading…
Reference in a new issue