Skip to content

Commit

Permalink
add help message for unzip
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Feb 27, 2024
1 parent 46b174e commit 124b6f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dria-cli",
"version": "0.0.8",
"version": "0.0.9",
"description": "A command-line tool for Dria",
"author": "FirstBatch Team <[email protected]>",
"contributors": [
Expand Down
41 changes: 26 additions & 15 deletions src/common/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,30 @@ export async function downloadAndUnzip(txId: string, outDir: string) {
});
});

await new Promise((resolve, reject) => {
createReadStream(tmpPath)
// unzips to out directory
.pipe(unzipper.Extract({ path: outDir, verbose: process.env.NODE_ENV !== "test" }))
.on("error", (err) => {
reject(err);
})
.on("close", () => {
logger.info("Knowledge extracted at", outDir);
logger.info("Cleaning up zip artifacts.");
rmSync(tmpPath);
logger.info("Done.");
resolve(true);
});
});
try {
await new Promise((resolve, reject) => {
createReadStream(tmpPath)
// unzips to out directory
.pipe(unzipper.Extract({ path: outDir, verbose: process.env.NODE_ENV !== "test" }))
.on("error", (err) => {
reject(err);
})
.on("close", () => {
logger.info("Knowledge extracted at", outDir);
logger.info("Cleaning up zip artifacts.");
rmSync(tmpPath);
logger.info("Done.");
resolve(true);
});
});
} catch (err) {
logger.error((err as Error).toString());

logger.info(`Something went wrong while extracting the downloaded zip file.
You can instead try unzipping via:
unzip ~/.dria/tmp/${txId}.zip -d ~/.dria/data
`);
}
}

0 comments on commit 124b6f9

Please sign in to comment.