From 58090f0ef2cc7676fc52e05a1a990911787bc44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=93=E5=8F=91=E5=8F=97=E9=95=BF=E7=94=9F?= Date: Wed, 15 May 2019 11:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=A0=E5=90=8C=E6=AD=A5=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=80=A7=E8=83=BD=E9=97=AE=E9=A2=98,=20?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=8E=BB=E6=8E=89hash=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy_utils/image_synchronize.js | 20 ++++++++++---------- deploy_utils/list_images.js | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/deploy_utils/image_synchronize.js b/deploy_utils/image_synchronize.js index 0f35951..5363d59 100644 --- a/deploy_utils/image_synchronize.js +++ b/deploy_utils/image_synchronize.js @@ -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) }) } diff --git a/deploy_utils/list_images.js b/deploy_utils/list_images.js index c417dc0..69d8c09 100644 --- a/deploy_utils/list_images.js +++ b/deploy_utils/list_images.js @@ -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') }) } })