Skip to content

Commit

Permalink
Calculate checksum without external module
Browse files Browse the repository at this point in the history
  • Loading branch information
niik committed Aug 18, 2022
1 parent 64c9f55 commit 057e287
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
},
"homepage": "https://github.com/desktop/dugite#readme",
"dependencies": {
"checksum": "^0.1.1",
"mkdirp": "^0.5.1",
"progress": "^2.0.3",
"rimraf": "^2.5.4",
"tar": "^6.1.11"
},
"devDependencies": {
"@types/checksum": "^0.1.30",
"@types/jest": "^28.1.7",
"@types/mkdirp": "^0.5.2",
"@types/node": "^11.9.0",
Expand Down
9 changes: 5 additions & 4 deletions script/download-git.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ const fs = require('fs')

const ProgressBar = require('progress')
const mkdirp = require('mkdirp')
const checksum = require('checksum')
const rimraf = require('rimraf')
const tar = require('tar')
const http = require('https')
const https = require('https')
const { createHash } = require('crypto')

const config = require('./config')()

const verifyFile = function(file, callback) {
checksum.file(file, { algorithm: 'sha256' }, (_, hash) => {
const h = createHash('sha256').on('finish', () => {
const hash = h.digest('hex')
const match = hash === config.checksum

if (!match) {
console.log(`Validation failed. Expected '${config.checksum}' but got '${hash}'`)
}

callback(match)
})

fs.createReadStream(file, { autoClose: true }).pipe(h)
}

const unpackFile = function(file) {
Expand Down
24 changes: 0 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,6 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/checksum@^0.1.30":
version "0.1.33"
resolved "https://registry.yarnpkg.com/@types/checksum/-/checksum-0.1.33.tgz#ad161fb7f878ccf946540f7d963c636d249251ed"
integrity sha512-fe6ZaTTh2Qk6J68EOKGz992sw6Y+sGK86skRTT4tz9Wxby6owinOXzHE73wBOw/ln7ty4rTbxjHx0RwjIM1LKw==

"@types/glob@*":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
Expand Down Expand Up @@ -912,13 +907,6 @@ char-regex@^1.0.2:
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==

checksum@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/checksum/-/checksum-0.1.1.tgz#dc6527d4c90be8560dbd1ed4cecf3297d528e9e9"
integrity sha512-xWkkJpoWQ6CptWw2GvtoQbScL3xtvGjoqvHpALE7B0tSHxSw0ex0tlsKOKkbETaOYGBhMliAyscestDyAZIN9g==
dependencies:
optimist "~0.3.5"

chownr@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece"
Expand Down Expand Up @@ -1900,13 +1888,6 @@ onetime@^5.1.2:
dependencies:
mimic-fn "^2.1.0"

optimist@~0.3.5:
version "0.3.7"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.3.7.tgz#c90941ad59e4273328923074d2cf2e7cbc6ec0d9"
integrity sha512-TCx0dXQzVtSCg2OgY/bO9hjM9cV4XYx09TVK+s3+FhkjT6LovsLe+pPMzpWf+6yXK/hUizs2gUoTw3jHM0VaTQ==
dependencies:
wordwrap "~0.0.2"

p-limit@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
Expand Down Expand Up @@ -2355,11 +2336,6 @@ which@^2.0.1:
dependencies:
isexe "^2.0.0"

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
integrity sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw==

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
Expand Down

0 comments on commit 057e287

Please sign in to comment.