Browse Source

fix: download same file return

ryanemax 6 months ago
parent
commit
2491600040
2 changed files with 4 additions and 2 deletions
  1. 2 1
      server/cloud/tbook/test/test-export.js
  2. 2 1
      server/lib/docs/index.js

+ 2 - 1
server/cloud/tbook/test/test-export.js

@@ -22,7 +22,8 @@ async function main(){
         // console.log(await exportProcessReportDocs("FR7KZtefyR"))
         // console.log("测试列表")
         // console.log(await exportProcessReportDocs(null,["9V575dapEM"]))
-        console.log(await exportProcessReportDocs(null,["F8eiOAfuC3"]))
+        // console.log(await exportProcessReportDocs(null,["F8eiOAfuC3"]))
+        console.log(await exportProcessReportDocs(null,["Oa1yB6n64u","j4pt2MMTXM","jAMGxwrl1F","BwZpEoOtS8","X10kCktA0r"]))
         // console.log(await exportProcessReportDocs(null,["BwZpEoOtS8","X10kCktA0r"]))
     }catch(err){
         console.error(err)

+ 2 - 1
server/lib/docs/index.js

@@ -129,7 +129,8 @@ async function downloadUrl(url) {
     let filepath = path.join(tempDir,filename)
     // console.log(filename,filepath)
     try{
-        if(fs.existsSync(filepath)){fs.rmSync(filepath)}
+        // if(fs.existsSync(filepath)){fs.rmSync(filepath)} // 存在则删除
+        if(fs.existsSync(filepath)){return filepath} // 存在则直接返回(md5相同)
         fs.writeFileSync(filepath, await download(url));
         return filepath
     }catch(err){