Skip to content

Commit

Permalink
Refactor: progress bar fixes & tweaks (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm committed Jun 11, 2024
1 parent e2d7d78 commit 073a975
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/console/progressBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import LogLevel from './logLevel.js';
export const ProgressBarSymbol = {
NONE: '',
WAITING: chalk.grey(process.platform === 'win32' ? '…' : '⋯'),
PROCESSING: chalk.cyan(process.platform === 'win32' ? '¤' : ''),
DONE: chalk.green(process.platform === 'win32' ? '' : ''),
// Files
SEARCHING: chalk.magenta(process.platform === 'win32' ? '○' : '↻'),
DOWNLOADING: chalk.magenta('↓'),
PARSING_CONTENTS: chalk.magenta('Σ'),
HASHING: chalk.magenta('#'),
DETECTING_HEADERS: chalk.magenta('^'),
INDEXING: chalk.magenta('#'),
// Processing a single DAT
GROUPING_SIMILAR: chalk.cyan('∩'),
Expand All @@ -26,9 +26,8 @@ export const ProgressBarSymbol = {
VALIDATING: chalk.cyan(process.platform === 'win32' ? '?' : '≟'),
COMBINING_ALL: chalk.cyan(process.platform === 'win32' ? 'U' : '∪'),
WRITING: chalk.yellow(process.platform === 'win32' ? '»' : '✎'),
RECYCLING: chalk.blue(process.platform === 'win32' ? '' : '♻'),
RECYCLING: chalk.blue(process.platform === 'win32' ? '»' : '♻'),
DELETING: chalk.red(process.platform === 'win32' ? 'X' : '✕'),
DONE: chalk.green(process.platform === 'win32' ? '√' : '✓'),
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/console/progressBarCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default class ProgressBarCLI extends ProgressBar {
this.singleBarFormatted?.getSingleBar().setTotal(total);
this.singleBarFormatted?.getSingleBar().update(0);
this.payload.inProgress = 0;
this.payload.waitingMessage = undefined;
return this.render(true);
}

Expand Down Expand Up @@ -290,6 +291,7 @@ export default class ProgressBarCLI extends ProgressBar {
this.singleBarFormatted?.getSingleBar().update(total + 1);
}

this.payload.waitingMessage = undefined;
if (finishedMessage) {
this.payload.finishedMessage = finishedMessage;
}
Expand Down
2 changes: 1 addition & 1 deletion src/igir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export default class Igir {
.index(romFilesWithHeaders);

await romProgressBar.setName(romScannerProgressBarName); // reset
await romProgressBar.doneItems(rawRomFiles.length, 'file', 'found');
await romProgressBar.doneItems(romFilesWithHeaders.length, 'file', 'found');
await romProgressBar.freeze();

return indexedRomFiles;
Expand Down
1 change: 1 addition & 0 deletions src/modules/patchScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class PatchScanner extends Scanner {
this.options.getReaderThreads(),
ChecksumBitmask.NONE,
);
await this.progressBar.reset(files.length);

const patches = (await new DriveSemaphore(this.options.getReaderThreads()).map(
files,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/romHeaderProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ROMHeaderProcessor extends Module {
}

this.progressBar.logTrace('processing file headers');
await this.progressBar.setSymbol(ProgressBarSymbol.HASHING);
await this.progressBar.setSymbol(ProgressBarSymbol.DETECTING_HEADERS);
await this.progressBar.reset(inputRomFiles.length);

const parsedFiles = await new DriveSemaphore(this.options.getReaderThreads()).map(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/romIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class ROMIndexer extends Module {
async index(files: File[]): Promise<IndexedFiles> {
this.progressBar.logTrace(`indexing ${files.length.toLocaleString()} file${files.length !== 1 ? 's' : ''}`);
await this.progressBar.setSymbol(ProgressBarSymbol.INDEXING);
// await this.progressBar.reset(files.length);
await this.progressBar.reset(files.length);

// Index the files
const result = IndexedFiles.fromFiles(files);
Expand Down

0 comments on commit 073a975

Please sign in to comment.