igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
67 lines (66 loc) • 2.55 kB
JavaScript
import { ProgressBarSymbol } from "../../console/progressBar.js";
import { ChecksumBitmask } from "../../models/files/fileChecksums.js";
import IntlUtil from "../../utils/intlUtil.js";
import Scanner from "../scanner.js";
class ROMScanner extends Scanner {
constructor(options, progressBar, fileFactory, mappableSemaphore) {
super(options, progressBar, fileFactory, mappableSemaphore, ROMScanner.name);
}
/**
* Scan for ROM files.
*/
async scan(checksumBitmask = ChecksumBitmask.CRC32, shouldChecksumArchives = false) {
this.prefixedLogger.trace("scanning ROM files");
this.progressBar.setSymbol(ProgressBarSymbol.FILE_SCANNING);
this.progressBar.resetProgress(0);
const inputFilePaths = await this.options.scanInputFilesWithoutExclusions((increment) => {
this.progressBar.incrementTotal(increment);
});
this.prefixedLogger.trace(
`found ${IntlUtil.toLocaleString(inputFilePaths.length)} input file${inputFilePaths.length === 1 ? "" : "s"}`
);
const filePathsToProcess = inputFilePaths;
const outputFilePathsSet = /* @__PURE__ */ new Set();
if (this.options.shouldPlaylist() || this.options.shouldClean() || this.options.shouldReport()) {
const inputFilePathsSet = new Set(inputFilePaths);
const outputFilePaths = await this.options.scanOutputFilesWithoutCleanExclusions(
[this.options.getOutputDirRoot()],
[],
(increment) => {
this.progressBar.incrementTotal(increment);
}
);
this.prefixedLogger.trace(
`found ${IntlUtil.toLocaleString(outputFilePaths.length)} output file${outputFilePaths.length === 1 ? "" : "s"}`
);
for (const filePath of outputFilePaths) {
if (inputFilePathsSet.has(filePath)) {
continue;
}
filePathsToProcess.push(filePath);
outputFilePathsSet.add(filePath);
}
}
this.progressBar.setSymbol(ProgressBarSymbol.ROM_HASHING);
this.progressBar.resetProgress(filePathsToProcess.length);
let files = await this.getFilesFromPaths(
filePathsToProcess,
checksumBitmask,
shouldChecksumArchives
);
if (outputFilePathsSet.size > 0) {
files = files.map((file) => {
if (!outputFilePathsSet.has(file.getFilePath())) {
return file;
}
return file.withProps({ canBeCandidateInput: false });
});
}
this.prefixedLogger.trace("done scanning ROM files");
return files;
}
}
export {
ROMScanner as default
};
//# sourceMappingURL=romScanner.js.map