因同步图片脚本性能问题, 暂时去掉hash比对
This commit is contained in:
parent
eebc90135b
commit
58090f0ef2
@ -55,11 +55,11 @@ class ImageSynchronizer {
|
||||
item.type = 'new'
|
||||
return true
|
||||
}
|
||||
else if (storageItems[index].eTag !== item.md5) {
|
||||
// 文件名存在, 但是hash值不同, 代表有变化
|
||||
item.type = 'change'
|
||||
return true
|
||||
}
|
||||
// else if (storageItems[index].eTag !== item.md5) {
|
||||
// // 文件名存在, 但是hash值不同, 代表有变化
|
||||
// item.type = 'change'
|
||||
// return true
|
||||
// }
|
||||
return false
|
||||
});
|
||||
// 处理待上传的文件
|
||||
@ -85,12 +85,12 @@ class ImageSynchronizer {
|
||||
}).then(result => {
|
||||
// eTag是上传后远端校验的md5值, 用于和本地进行比对
|
||||
let eTag = result.eTag.replace(/"/g,'')
|
||||
if(filesList[index].md5 === eTag) {
|
||||
// if(filesList[index].md5 === eTag) {
|
||||
console.log(`${filesList[index].name} 上传成功, md5:${eTag} 类型: ${filesList[index].type}`)
|
||||
} else {
|
||||
console.warn(`${filesList[index].name} 上传出错, md5值不一致`)
|
||||
console.warn(`===> 本地文件: ${filesList[index].md5}, 接口返回: ${eTag}`)
|
||||
}
|
||||
// } else {
|
||||
// console.warn(`${filesList[index].name} 上传出错, md5值不一致`)
|
||||
// console.warn(`===> 本地文件: ${filesList[index].md5}, 接口返回: ${eTag}`)
|
||||
// }
|
||||
this._uploadObject(filesList, ++index)
|
||||
})
|
||||
}
|
||||
|
||||
@ -17,12 +17,12 @@ function readDirSync(imageFolderPath, images, rootPath){
|
||||
readDirSync(`${imageFolderPath}/${item}`, images, rootPath)
|
||||
}else{
|
||||
//读取一个Buffer
|
||||
let buffer = fs.readFileSync(`${imageFolderPath}/${item}`)
|
||||
let fsHash = crypto.createHash('md5')
|
||||
fsHash.update(buffer)
|
||||
// let buffer = fs.readFileSync(`${imageFolderPath}/${item}`)
|
||||
// let fsHash = crypto.createHash('md5')
|
||||
// fsHash.update(buffer)
|
||||
images.push({
|
||||
name: `${imageFolderPath}/${item}`.replace(rootPath, ''),
|
||||
md5: fsHash.digest('hex')
|
||||
// md5: fsHash.digest('hex')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user