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:
parent
aa68c18246
commit
2a682c76be
6
index.js
6
index.js
@ -28,7 +28,7 @@ export default async function downloader(downloadUrl, checksumUrl, options) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// validate the checksum of the download
|
// 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
|
// optionally clear the target directory of existing files
|
||||||
if (options.cleanDestDir) {
|
if (options.cleanDestDir) {
|
||||||
@ -64,8 +64,8 @@ async function downloadFile(url, dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check da checksum.
|
// Check da checksum.
|
||||||
async function checkChecksum(baseDir, checksumFile, downloadFile, algorithm, encoding) {
|
async function checkChecksum(baseDir, downloadFile, checksumFile, algorithm, encoding) {
|
||||||
const checker = new sumchecker.ChecksumValidator(algorithm, checksumFile, {
|
const checker = new sumchecker.ChecksumValidator(algorithm, path.join(baseDir, checksumFile), {
|
||||||
defaultTextEncoding: encoding,
|
defaultTextEncoding: encoding,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user