瀏覽代碼

v3场景下载

dengsixing 2 年之前
父節點
當前提交
2d59756f59
共有 1 個文件被更改,包括 7 次插入12 次删除
  1. 7 12
      src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

+ 7 - 12
src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -350,10 +350,9 @@ public class SceneDownloadHandlerServiceImpl {
             //写入启动命令
             this.zipBat(out, num, "v3");
 
+            //打压缩包
             ZipUtil.zip(String.format(this.sourceLocal, num, ""), zipPath);
 
-//            out.close();
-
             //上传压缩包
             String uploadPath = String.format(this.zipOssFormat, num);
             fYunFileService.uploadFileByCommand(bucket, zipPath, uploadPath);
@@ -367,10 +366,8 @@ public class SceneDownloadHandlerServiceImpl {
             this.updateProgress( null, num, SceneDownloadProgressStatus.DOWNLOAD_FAILED.code(), null, "v3");
             throw e;
         }finally {
-            if(Objects.nonNull(out)){
-                //删除本地zip包
-//                FileUtils.deleteFile(zipPath);
-            }
+            FileUtil.del(zipPath);
+            FileUtil.del(String.format(this.sourceLocal, num, ""));
         }
     }
 
@@ -436,10 +433,6 @@ public class SceneDownloadHandlerServiceImpl {
         int imagesVersion, Set<String> cacheKeys,
         String filePath, String imageNumPath, String version) throws Exception{
 
-        //更新进度
-        this.updateProgress(new BigDecimal(count.incrementAndGet()).divide(new BigDecimal(total), 6, BigDecimal.ROUND_HALF_UP),
-            num, SceneDownloadProgressStatus.DOWNLOADING.code(), null, version);
-
         //某个目录不需要打包
         if(filePath.contains(imageNumPath + "panorama/panorama_edit/"))
             return;
@@ -455,6 +448,10 @@ public class SceneDownloadHandlerServiceImpl {
 
         //其他文件打包
         this.ProcessFiles(num, filePath, out, this.wwwroot, cacheKeys);
+
+        //更新进度
+        this.updateProgress(new BigDecimal(count.incrementAndGet()).divide(new BigDecimal(total), 6, BigDecimal.ROUND_HALF_UP),
+            num, SceneDownloadProgressStatus.DOWNLOADING.code(), null, version);
     }
 
     private void zipLocalFiles(ZipOutputStream out, List<String> localFilePaths, String v3localPath, String num, AtomicInteger count, int total, String version) throws Exception{
@@ -652,10 +649,8 @@ public class SceneDownloadHandlerServiceImpl {
                 .replace("https://spc.html","spc.html")
                 .replace("https://smobile.html", "smobile.html");
 
-//            zipBytes(out, prefix + key, content.getBytes());
             FileUtil.writeUtf8String(content, String.format(sourceLocal, num, prefix + key));
         }else{
-//            zipBytes(out, prefix + key, FileUtils.getBytesFromUrl(url));
             HttpUtil.downloadFile(url, String.format(sourceLocal, num, prefix + key));
         }
     }