Skip to content

Commit

Permalink
added timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmel committed Jan 21, 2024
1 parent dbbc9d2 commit 9a18fd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

All notable changes to the extension will be documented in this file.

## [1.0.10] - 2024-02-

- Add file progress for long running archives

## [1.0.9] - 2024-01-21

- Option to exclude `.git` folders
Expand Down
12 changes: 10 additions & 2 deletions src/provider.ts
Expand Up @@ -42,7 +42,8 @@ export async function archive() {
const date = new Date();
const arch = `${name}_${date.toISOString().replace(/[:.Z]/g, "")}.zip`;
const dest = path.join(root, arch);
const msg = window.setStatusBarMessage(`Archiving ${name} ...`);
const status = window.createStatusBarItem();
const timeout = setTimeout(() => status.show(), 1000);

try {
const output = createWriteStream(dest);
Expand All @@ -56,6 +57,12 @@ export async function archive() {
window.showErrorMessage(`Failed to archive: ${err}`)
);

archive.on(
"progress",
(data) =>
(status.text = `Archiving ${name} (${data.entries.processed} of ${data.entries.total})`)
);

archive.on("end", () =>
window.showInformationMessage(`Archived ${files.length} files to ${arch}`)
);
Expand All @@ -68,6 +75,7 @@ export async function archive() {

await archive.finalize();
} finally {
msg.dispose();
clearTimeout(timeout);
status.dispose();
}
}

0 comments on commit 9a18fd9

Please sign in to comment.