Use SHA256 for cache filenames, camelCase function
This commit is contained in:
parent
2ac18b6ce4
commit
668659b233
|
@ -4,7 +4,7 @@ import fs from 'fs-extra'
|
||||||
|
|
||||||
const engines = [ require('./preview/image'), require('./preview/ffmpeg'), require('./preview/unoconv') ]
|
const engines = [ require('./preview/image'), require('./preview/ffmpeg'), require('./preview/unoconv') ]
|
||||||
|
|
||||||
const cache_name = file => crypto.createHash('sha1').update(file.fullpath).digest('hex')
|
const cacheName = file => crypto.createHash('sha256').update(file.fullpath).digest('hex')
|
||||||
|
|
||||||
module.exports = (files, cache_path) => {
|
module.exports = (files, cache_path) => {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ module.exports = (files, cache_path) => {
|
||||||
const preview = async file => {
|
const preview = async file => {
|
||||||
const p = engines.find(p => p.preview && p.detect(file))
|
const p = engines.find(p => p.preview && p.detect(file))
|
||||||
if (p) {
|
if (p) {
|
||||||
const dest = path.join(cache_path, cache_name(file)) + '.' + p.ext(file)
|
const dest = path.join(cache_path, cacheName(file)) + '.' + p.ext(file)
|
||||||
if (!await fs.pathExists(dest)) await p.preview(file.fullpath, dest)
|
if (!await fs.pathExists(dest)) await p.preview(file.fullpath, dest)
|
||||||
return dest
|
return dest
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue