Revert previous changes and save hash to new field sha256

This commit is contained in:
Jakub Skořepa 2018-08-09 19:46:23 +02:00
parent 2ad3121494
commit 4771cc9575
No known key found for this signature in database
GPG Key ID: BD9002D794BC3871
2 changed files with 8 additions and 2 deletions

View File

@ -18,6 +18,10 @@
"configurable": false,
"required": true
},
"sha256": {
"type": "string",
"configurable": false
},
"ext": {
"type": "string",
"configurable": false
@ -48,4 +52,4 @@
"configurable": false
}
}
}
}

View File

@ -10,6 +10,7 @@ const fs = require('fs');
const _ = require('lodash');
const toArray = require('stream-to-array');
const crypto = require('crypto');
const uuid = require('uuid/v4');
function niceHash(buffer) {
return crypto.createHash('sha256')
@ -41,7 +42,8 @@ module.exports = {
return {
name: stream.name,
hash: niceHash(buffer),
sha256: niceHash(buffer),
hash: uuid().replace(/-/g, ''),
ext: stream.name.split('.').length > 1 ? `.${_.last(stream.name.split('.'))}` : '',
buffer,
mime: stream.type,