mirror of https://github.com/tycrek/ass
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
608 B
14 lines
608 B
const fs = require('fs-extra');
|
|
const crypto = require('crypto');
|
|
const toArray = require('stream-to-array')
|
|
const { path } = require('./utils');
|
|
const { s3enabled, diskFilePath } = require('./config.json');
|
|
|
|
module.exports = (file) =>
|
|
new Promise((resolve, reject) =>
|
|
toArray((fs.createReadStream(s3enabled ? path(diskFilePath, file.originalname) : path(file.path))))
|
|
.then((parts) => Buffer.concat(parts.map((part) => (Buffer.isBuffer(part) ? part : Buffer.from(part)))))
|
|
.then((buf) => crypto.createHash('sha1').update(buf).digest('hex')) // skipcq: JS-D003
|
|
.then(resolve)
|
|
.catch(reject));
|