How to use sumchecker - 7 common examples

To help you get started, we’ve selected a few sumchecker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-builder / packages / app-builder-lib / src / electron / electron-download.ts View on Github external
private async verifyFile(cachedFile: string, removeIfInvalid: boolean): Promise {
    if (!this.options.isVerifyChecksum) {
      return true
    }

    debug("Verifying file with checksum")
    if (!await pathExists(this.cachedChecksum)) {
      await this.downloadFile(this.checksumUrl, this.cachedChecksum)
    }

    const checker = new ChecksumValidator("sha256", this.cachedChecksum)
    try {
      await checker.validate(path.dirname(cachedFile), path.basename(cachedFile))
    }
    catch (e) {
      if (!removeIfInvalid) {
        throw e
      }

      try {
        await unlink(cachedFile)
      }
      catch (ignore) {
        // ignore
      }
      return false
    }
github electron / electron / script / release / release.js View on Github external
.catch(err => {
      if (err instanceof sumchecker.ChecksumMismatchError) {
        console.error(`${fail} The checksum of ${err.filename} from ` +
          `${validationArgs.fileSource} did not match the shasum in ` +
          `${validationArgs.shaSumFile}`)
      } else if (err instanceof sumchecker.ChecksumParseError) {
        console.error(`${fail} The checksum file ${validationArgs.shaSumFile} ` +
          `from ${validationArgs.fileSource} could not be parsed.`, err)
      } else if (err instanceof sumchecker.NoChecksumFoundError) {
        console.error(`${fail} The file ${err.filename} from ` +
          `${validationArgs.fileSource} was not in the shasum file ` +
          `${validationArgs.shaSumFile}.`)
      } else {
        console.error(`${fail} Error matching files from ` +
          `${validationArgs.fileSource} shasums in ${validationArgs.shaSumFile}.`, err)
      }
      process.exit(1)
    })
github electron / electron / script / release / release.js View on Github external
.catch(err => {
      if (err instanceof sumchecker.ChecksumMismatchError) {
        console.error(`${fail} The checksum of ${err.filename} from ` +
          `${validationArgs.fileSource} did not match the shasum in ` +
          `${validationArgs.shaSumFile}`)
      } else if (err instanceof sumchecker.ChecksumParseError) {
        console.error(`${fail} The checksum file ${validationArgs.shaSumFile} ` +
          `from ${validationArgs.fileSource} could not be parsed.`, err)
      } else if (err instanceof sumchecker.NoChecksumFoundError) {
        console.error(`${fail} The file ${err.filename} from ` +
          `${validationArgs.fileSource} was not in the shasum file ` +
          `${validationArgs.shaSumFile}.`)
      } else {
        console.error(`${fail} Error matching files from ` +
          `${validationArgs.fileSource} shasums in ${validationArgs.shaSumFile}.`, err)
      }
      process.exit(1)
    })
  console.log(`${pass} All files from ${validationArgs.fileSource} match ` +
github electron / electron / script / release / release.js View on Github external
.catch(err => {
      if (err instanceof sumchecker.ChecksumMismatchError) {
        console.error(`${fail} The checksum of ${err.filename} from ` +
          `${validationArgs.fileSource} did not match the shasum in ` +
          `${validationArgs.shaSumFile}`)
      } else if (err instanceof sumchecker.ChecksumParseError) {
        console.error(`${fail} The checksum file ${validationArgs.shaSumFile} ` +
          `from ${validationArgs.fileSource} could not be parsed.`, err)
      } else if (err instanceof sumchecker.NoChecksumFoundError) {
        console.error(`${fail} The file ${err.filename} from ` +
          `${validationArgs.fileSource} was not in the shasum file ` +
          `${validationArgs.shaSumFile}.`)
      } else {
        console.error(`${fail} Error matching files from ` +
          `${validationArgs.fileSource} shasums in ${validationArgs.shaSumFile}.`, err)
      }
      process.exit(1)
    })
  console.log(`${pass} All files from ${validationArgs.fileSource} match ` +
github electron / electron / script / release / release.js View on Github external
async function validateChecksums (validationArgs) {
  console.log(`Validating checksums for files from ${validationArgs.fileSource} ` +
    `against ${validationArgs.shaSumFile}.`)
  const shaSumFilePath = path.join(validationArgs.fileDirectory, validationArgs.shaSumFile)
  const checker = new sumchecker.ChecksumValidator(validationArgs.algorithm,
    shaSumFilePath, validationArgs.checkerOpts)
  await checker.validate(validationArgs.fileDirectory, validationArgs.filesToCheck)
    .catch(err => {
      if (err instanceof sumchecker.ChecksumMismatchError) {
        console.error(`${fail} The checksum of ${err.filename} from ` +
          `${validationArgs.fileSource} did not match the shasum in ` +
          `${validationArgs.shaSumFile}`)
      } else if (err instanceof sumchecker.ChecksumParseError) {
        console.error(`${fail} The checksum file ${validationArgs.shaSumFile} ` +
          `from ${validationArgs.fileSource} could not be parsed.`, err)
      } else if (err instanceof sumchecker.NoChecksumFoundError) {
        console.error(`${fail} The file ${err.filename} from ` +
          `${validationArgs.fileSource} was not in the shasum file ` +
          `${validationArgs.shaSumFile}.`)
      } else {
        console.error(`${fail} Error matching files from ` +
github Sn8z / Poddr / node_modules / electron-chromedriver / node_modules / electron-download / lib / index.js View on Github external
verifyChecksum (cb) {
    let options = {}
    if (semver.lt(this.version, '1.3.5')) {
      options.defaultTextEncoding = 'binary'
    }
    let checker = new sumchecker.ChecksumValidator('sha256', this.cachedChecksum, options)
    checker.validate(this.cache, this.filename).then(() => {
      cb(null, this.cachedZip)
    }, (err) => {
      fs.unlink(this.cachedZip, (fsErr) => {
        if (fsErr) return cb(fsErr)
        cb(err)
      })
    })
  }
}
github cellardoor42 / whatever / node_modules / electron-download / build / index.js View on Github external
value: function verifyChecksum(cb) {
      var _this7 = this;

      var options = {};
      if (semver.lt(this.version, '1.3.5')) {
        options.defaultTextEncoding = 'binary';
      }
      var checker = new sumchecker.ChecksumValidator('sha256', this.cachedChecksum, options);
      checker.validate(this.cache, this.filename).then(function () {
        cb(null, _this7.cachedZip);
      }, function (err) {
        fs.unlink(_this7.cachedZip, function (fsErr) {
          if (fsErr) return cb(fsErr);
          cb(err);
        });
      });
    }
  }, {

sumchecker

Checksum validator

Apache-2.0
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis