Skip to content

Commit

Permalink
Use inly to extract
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jul 12, 2024
1 parent 87ce217 commit 68b1547
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"dependencies": {
"cli-progress": "^3.12.0",
"inly": "^5.0.1",
"pinyin-pro": "^3.18.5",
"yomichan-dict-builder": "^2.6.0"
},
Expand Down
7 changes: 6 additions & 1 deletion src/util/downloadDumps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { $ } from 'bun';
import { exists, mkdir } from 'node:fs/promises';
import { join } from 'path';
import { LanguageCode } from '../constants';
const inly = require('inly');

const ARCHIVE = (lang: string) =>
`short-abstracts_lang=${lang.toLowerCase()}.ttl.bz2`;
Expand Down Expand Up @@ -44,7 +45,11 @@ export async function downloadDumps(lang: LanguageCode, date: string) {
// Extract the archive if it does not exist
if (!fileExists) {
console.log(`Extracting ${archivePath}`);
await $`bzip2 -dc ${archivePath} >${filePath}`;
const extract = inly(archivePath, DOWNLOAD_DIR);
await new Promise((resolve, reject) => {
extract.on('error', reject);
extract.on('end', resolve);
});
}

console.log(`Finished downloading and extracting ${lang} dump`);
Expand Down

0 comments on commit 68b1547

Please sign in to comment.