mirror of
https://github.com/catdevnull/transicion-desordenada-diablo
synced 2024-11-15 10:31:38 +00:00
downloader: formatting
This commit is contained in:
parent
5aa96adc8d
commit
49bde3947c
1 changed files with 9 additions and 9 deletions
|
@ -9,7 +9,7 @@ import { zData } from "common/schema.js";
|
||||||
setGlobalDispatcher(
|
setGlobalDispatcher(
|
||||||
new Agent({
|
new Agent({
|
||||||
pipelining: 0,
|
pipelining: 0,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
/** key es host
|
/** key es host
|
||||||
|
@ -43,7 +43,7 @@ const targets = urls.map((url) => {
|
||||||
});
|
});
|
||||||
for (const target of targets)
|
for (const target of targets)
|
||||||
downloadFromData(target).catch((error) =>
|
downloadFromData(target).catch((error) =>
|
||||||
console.error(`${target.type}+${target.url} FALLÓ CON`, error)
|
console.error(`${target.type}+${target.url} FALLÓ CON`, error),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +86,7 @@ async function downloadFromData(target) {
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.map((dist) => ({
|
.map((dist) => ({
|
||||||
dataset,
|
dataset,
|
||||||
|
@ -94,7 +94,7 @@ async function downloadFromData(target) {
|
||||||
url: patchUrl(new URL(dist.downloadURL)),
|
url: patchUrl(new URL(dist.downloadURL)),
|
||||||
outputPath,
|
outputPath,
|
||||||
attempts: 0,
|
attempts: 0,
|
||||||
}))
|
})),
|
||||||
);
|
);
|
||||||
const totalJobs = jobs.length;
|
const totalJobs = jobs.length;
|
||||||
let nFinished = 0;
|
let nFinished = 0;
|
||||||
|
@ -126,7 +126,7 @@ async function downloadFromData(target) {
|
||||||
process.stderr.write(`info[${outputPath}]: 0/${totalJobs} done\n`);
|
process.stderr.write(`info[${outputPath}]: 0/${totalJobs} done\n`);
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
process.stderr.write(
|
process.stderr.write(
|
||||||
`info[${outputPath}]: ${nFinished}/${totalJobs} done\n`
|
`info[${outputPath}]: ${nFinished}/${totalJobs} done\n`,
|
||||||
);
|
);
|
||||||
}, 30000);
|
}, 30000);
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
@ -204,12 +204,12 @@ async function downloadDist({ dist, dataset, url, outputPath }) {
|
||||||
const fileDirPath = join(
|
const fileDirPath = join(
|
||||||
outputPath,
|
outputPath,
|
||||||
sanitizeSuffix(dataset.identifier),
|
sanitizeSuffix(dataset.identifier),
|
||||||
sanitizeSuffix(dist.identifier)
|
sanitizeSuffix(dist.identifier),
|
||||||
);
|
);
|
||||||
await mkdir(fileDirPath, { recursive: true });
|
await mkdir(fileDirPath, { recursive: true });
|
||||||
const filePath = join(
|
const filePath = join(
|
||||||
fileDirPath,
|
fileDirPath,
|
||||||
sanitizeSuffix(dist.fileName || dist.identifier)
|
sanitizeSuffix(dist.fileName || dist.identifier),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!res.body) throw new Error("no body");
|
if (!res.body) throw new Error("no body");
|
||||||
|
@ -239,11 +239,11 @@ function sanitizeSuffix(path) {
|
||||||
*/
|
*/
|
||||||
function chequearIdsDuplicados(jobs, id) {
|
function chequearIdsDuplicados(jobs, id) {
|
||||||
const duplicated = hasDuplicates(
|
const duplicated = hasDuplicates(
|
||||||
jobs.map((j) => `${j.dataset.identifier}/${j.dist.identifier}`)
|
jobs.map((j) => `${j.dataset.identifier}/${j.dist.identifier}`),
|
||||||
);
|
);
|
||||||
if (duplicated) {
|
if (duplicated) {
|
||||||
console.error(
|
console.error(
|
||||||
`ADVERTENCIA[${id}]: ¡encontré duplicados! es posible que se pisen archivos entre si`
|
`ADVERTENCIA[${id}]: ¡encontré duplicados! es posible que se pisen archivos entre si`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue