1
mirror of https://github.com/jakejarvis/careful-downloader.git synced 2026-01-14 06:42:56 -05:00

fs.exists() (deprecated) -> fs.access()

This commit is contained in:
2021-10-16 09:53:32 -04:00
parent efbca27fd0
commit 9454810eab
2 changed files with 5 additions and 5 deletions

View File

@@ -50,7 +50,7 @@ export const checksumViaString = async (desiredFile, correctHash, algorithm, enc
// Takes a path to a file and returns its hash.
const generateHashFromFile = async (file, algorithm, encoding) => {
const fileBuffer = fs.readFileSync(file);
const fileBuffer = await fs.readFile(file);
const hashSum = crypto.createHash(algorithm);
hashSum.update(fileBuffer);
@@ -61,7 +61,7 @@ const generateHashFromFile = async (file, algorithm, encoding) => {
// https://github.com/malept/sumchecker/blob/28aed640a02787490d033fda56eaee30e24e5a71/src/index.ts#L97
const parseChecksumFile = async (checksumFile) => {
// read the text file holding one or more checksums
const data = fs.readFileSync(checksumFile, { encoding: "utf8" });
const data = await fs.readFile(checksumFile, { encoding: "utf8" });
// https://regexr.com/67k7i
const lineRegex = /^([\da-fA-F]+)[ \t]+[*]?(.+)$/;