diff options
Diffstat (limited to 'net-im/signal-desktop/files/download.js')
-rw-r--r-- | net-im/signal-desktop/files/download.js | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/net-im/signal-desktop/files/download.js b/net-im/signal-desktop/files/download.js deleted file mode 100644 index 490686bf7ed8..000000000000 --- a/net-im/signal-desktop/files/download.js +++ /dev/null @@ -1,63 +0,0 @@ -const https = require('https'); -const fs = require('fs'); -const path = require('path'); -const crypto = require('crypto'); -const { Transform } = require('stream'); -const { pipeline } = require('stream/promises'); - -const BASE_URI = `https://build-artifacts.signal.org/desktop`; -const HASH = 'b633825cf7e0fdd39a6cdf128f2bd76552a88d325f2b9cd07bb87a457cefb986'; -const SQLCIPHER_VERSION = '4.5.3-fts'; -const OPENSSL_VERSION = '3.0.7'; -const TOKENIZER_VERSION = '0.2.1'; -const TAG = [SQLCIPHER_VERSION, OPENSSL_VERSION, TOKENIZER_VERSION].join('--'); -const URL = `${BASE_URI}/sqlcipher-${TAG}-${HASH}.tar.gz`; - -const tmpFile = path.join(__dirname, 'unverified.tmp'); -const finalFile = path.join(__dirname, 'sqlcipher.tar.gz'); - -async function main() { - return; - if (fs.statSync(finalFile, { throwIfNoEntry: false })) { - const hash = crypto.createHash('sha256'); - const existingHash = await pipeline( - fs.createReadStream(finalFile), - hash, - ); - if (hash.digest('hex') === HASH) { - console.log('local build artifact is up-to-date'); - return; - } - - console.log('local build artifact is outdated'); - } - download(); -} - -function download() { - console.log(`downloading ${URL}`); - https.get(URL, async (res) => { - const out = fs.createWriteStream(tmpFile); - - const hash = crypto.createHash('sha256'); - - const t = new Transform({ - transform(chunk, encoding, callback) { - hash.write(chunk, encoding); - callback(null, chunk); - } - }); - - await pipeline(res, t, out); - - const actualDigest = hash.digest('hex'); - if (actualDigest !== HASH) { - fs.unlinkSync(tmpFile); - throw new Error(`Digest mismatch. Expected ${HASH} got ${actualDigest}`); - } - - fs.renameSync(tmpFile, finalFile); - }) -} - -main(); |