mirror of
https://github.com/sbrl/research-rainfallradar
synced 2024-11-25 10:32:59 +00:00
recompress files in the right order
This commit is contained in:
parent
3332fa598a
commit
927c30e189
2 changed files with 9 additions and 3 deletions
|
@ -15,11 +15,17 @@ async function records_recompress(dirpath_source, dirpath_target, items_per_file
|
||||||
.filter(filename => filename.endsWith(`.jsonl.gz`))
|
.filter(filename => filename.endsWith(`.jsonl.gz`))
|
||||||
.map(filename => path.join(dirpath_source, filename));
|
.map(filename => path.join(dirpath_source, filename));
|
||||||
|
|
||||||
|
files.sort((a, b) => {
|
||||||
|
let ai = parseInt(a.split(".")[0], 10), bi = parseInt(b.split(".")[0], 10);
|
||||||
|
if(ai === bi) return 0;
|
||||||
|
else return ai > bi ? 1 : -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
const reader = nexline({
|
const reader = nexline({
|
||||||
input: files.map(filepath => new Readable().wrap(fs.createReadStream(filepath).pipe(gunzip())))
|
input: files.map(filepath => new Readable().wrap(fs.createReadStream(filepath).pipe(gunzip())))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if(!fs.existsSync(dirpath_target))
|
if(!fs.existsSync(dirpath_target))
|
||||||
await fs.promises.mkdir(dirpath_target, { recursive: true });
|
await fs.promises.mkdir(dirpath_target, { recursive: true });
|
||||||
|
|
||||||
|
|
|
@ -17,5 +17,5 @@ export default async function() {
|
||||||
if(!fs.existsSync(settings.target))
|
if(!fs.existsSync(settings.target))
|
||||||
await fs.promises.mkdir(settings.target);
|
await fs.promises.mkdir(settings.target);
|
||||||
|
|
||||||
await records_recompress(settings.source, settings.target);
|
await records_recompress(settings.source, settings.target, settings.count_file);
|
||||||
}
|
}
|
Loading…
Reference in a new issue