Skip to content

Commit

Permalink
Feature: DAT downloading & parsing progress bar icons (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Oct 23, 2023
1 parent 5e44cb6 commit bb6cade
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/console/progressBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export const ProgressBarSymbol = {
WAITING: chalk.grey(process.platform === 'win32' ? '…' : '⋯'),
PROCESSING: chalk.cyan(process.platform === 'win32' ? '¤' : '⚙'),
// Files
DOWNLOADING: chalk.magenta('↓'),
SEARCHING: chalk.magenta(process.platform === 'win32' ? '○' : '↻'),
DOWNLOADING: chalk.magenta('↓'),
PARSING_CONTENTS: chalk.magenta('Σ'),
HASHING: chalk.magenta('#'),
INDEXING: chalk.magenta('#'),
// DATs
// Processing a single DAT
GROUPING_SIMILAR: chalk.cyan('∩'),
MERGE_SPLIT: chalk.cyan('↔'),
// Candidates
Expand Down
1 change: 1 addition & 0 deletions src/modules/datScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class DATScanner extends Scanner {
// Parse each file into a DAT
private async parseDatFiles(datFiles: File[]): Promise<DAT[]> {
this.progressBar.logDebug(`parsing ${datFiles.length.toLocaleString()} DAT file${datFiles.length !== 1 ? 's' : ''}`);
await this.progressBar.setSymbol(ProgressBarSymbol.PARSING_CONTENTS);

const results = (await async.mapLimit(
datFiles,
Expand Down
3 changes: 3 additions & 0 deletions src/types/files/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import path from 'node:path';
import { Readable } from 'node:stream';
import util from 'node:util';

import { Memoize } from 'typescript-memoize';

import Constants from '../../constants.js';
import ArrayPoly from '../../polyfill/arrayPoly.js';
import FilePoly from '../../polyfill/filePoly.js';
Expand Down Expand Up @@ -171,6 +173,7 @@ export default class File implements FileProps {
return this.patch;
}

@Memoize()
isURL(): boolean {
return URLPoly.canParse(this.getFilePath());
}
Expand Down

0 comments on commit bb6cade

Please sign in to comment.