Skip to content

Commit

Permalink
fix: 💄 display filename before download start
Browse files Browse the repository at this point in the history
  • Loading branch information
JiPaix committed Sep 5, 2020
1 parent d48348f commit 1605b25
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default class Downloader extends CtcpParser {
pick: number | undefined
): void {
candidate.cancel = this.makeCancelable(candidate, client)
this.print(`%info% downloading : %cyan% ${fileInfo.file}`, 5)
const bar = this.setupProgressBar(fileInfo.length)
const pass: Pass = {
server: server,
Expand Down Expand Up @@ -173,8 +174,8 @@ export default class Downloader extends CtcpParser {

private onEnd(args: Pass): void {
args.client.on('end', () => {
this.print('%success% done.', 6)
args.candidate.timeout.clear()
this.print('%success% done : %cyan%' + args.fileInfo.file, 8)
args.candidate.success.push(args.fileInfo.file)
if (args.server && args.pick) {
args.server.close(() => {
Expand Down Expand Up @@ -236,14 +237,12 @@ export default class Downloader extends CtcpParser {
}

protected setupProgressBar(len: number): ProgressBar {
return new ProgressBar(
`\u2937 `.padStart(6) + Connect.replace('%success% downloading [:bar] ETA: :eta @ :rate - :percent'),
{
complete: '=',
incomplete: ' ',
width: 20,
total: len,
}
)
return new ProgressBar(`\u2937 `.padStart(6) + Connect.replace('[:bar] ETA: :eta @ :rate - :percent'), {
complete: '=',
incomplete: ' ',
width: 20,
total: len,
clear: true,
})
}
}

0 comments on commit 1605b25

Please sign in to comment.