dengsixing před 3 roky
rodič
revize
99c03909ea

+ 15 - 2
src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -255,6 +255,9 @@ public class SceneDownloadHandlerServiceImpl {
 
     private void zipOssFiles(ZipOutputStream out, List<String> ossFilePaths, String num, AtomicInteger count,
         int total, String resolution, int imagesVersion, Set<String> cacheKeys) throws Exception{
+        if(CollUtil.isEmpty(ossFilePaths)){
+            return;
+        }
         String imageNumPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
         ExecutorService executorService = Executors.newFixedThreadPool(this.zipNthreads);
         List<Future> futureList = new ArrayList<>();
@@ -270,8 +273,17 @@ public class SceneDownloadHandlerServiceImpl {
             futureList.add(executorService.submit(call));
         }
         //这里一定要加阻塞,不然会导致oss文件还没打包好,主程序已经结束返回了
+        Boolean zipSuccess = true;
         for (Future future : futureList) {
-            future.get();
+            try {
+                future.get();
+            }catch (Exception e){
+                log.error("打包oss文件失败", e);
+                zipSuccess = false;
+            }
+        }
+        if(!zipSuccess){
+            throw new Exception("打包oss文件失败");
         }
     }
 
@@ -463,7 +475,8 @@ public class SceneDownloadHandlerServiceImpl {
             return;
         }
         cacheKeys.add(key);
-        String url = this.resourceUrl + key + "?t=" + Calendar.getInstance().getTimeInMillis();
+        String fileName = key.substring(key.lastIndexOf("/") + 1);
+        String url = this.resourceUrl + key.replace(fileName, URLEncoder.encode(fileName, "UTF-8")) + "?t=" + Calendar.getInstance().getTimeInMillis();
         if(key.contains("hot.json") || key.contains("link-scene.json")){
             String content = FileUtils.getStringFromUrl(url);