1
mirror of https://github.com/jakejarvis/careful-downloader.git synced 2025-04-26 07:45:23 -04:00

refactor checkChecksum()

This commit is contained in:
Jake Jarvis 2021-10-06 09:49:06 -04:00
parent aa68c18246
commit 2a682c76be
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

View File

@ -28,7 +28,7 @@ export default async function downloader(downloadUrl, checksumUrl, options) {
]);
// validate the checksum of the download
await checkChecksum(options.tempDir, path.join(options.tempDir, "checksums.txt"), options.filename, options.algorithm, options.encoding);
await checkChecksum(options.tempDir, options.filename, "checksums.txt", options.algorithm, options.encoding);
// optionally clear the target directory of existing files
if (options.cleanDestDir) {
@ -64,8 +64,8 @@ async function downloadFile(url, dest) {
}
// Check da checksum.
async function checkChecksum(baseDir, checksumFile, downloadFile, algorithm, encoding) {
const checker = new sumchecker.ChecksumValidator(algorithm, checksumFile, {
async function checkChecksum(baseDir, downloadFile, checksumFile, algorithm, encoding) {
const checker = new sumchecker.ChecksumValidator(algorithm, path.join(baseDir, checksumFile), {
defaultTextEncoding: encoding,
});