Selaa lähdekoodia

update oss status.json

lyhzzz 2 vuotta sitten
vanhempi
commit
c904911693

+ 15 - 11
src/main/java/com/fdkankan/ucenter/service/impl/SceneCommonService.java

@@ -132,28 +132,30 @@ public class SceneCommonService {
             fileContent = fYunFileServiceInterface.getFileContent(ossStatusJsonPath);
             fileContent = fYunFileServiceInterface.getFileContent(ossStatusJsonPath);
         }
         }
 
 
-
         if(StringUtils.isNotBlank(fileContent)){
         if(StringUtils.isNotBlank(fileContent)){
             String localPath = SceneResourcePath.nasBasePath + targetPath +"/scene.json";
             String localPath = SceneResourcePath.nasBasePath + targetPath +"/scene.json";
             File file = new File(localPath);
             File file = new File(localPath);
             if(!file.getParentFile().exists()){
             if(!file.getParentFile().exists()){
-                file.mkdirs();
+                file.getParentFile().mkdirs();
             }
             }
             String newJson = fileContent.replaceAll(oldNum,newNum);
             String newJson = fileContent.replaceAll(oldNum,newNum);
             newJson = newJson.replaceAll(oldSceneName,newSceneName);
             newJson = newJson.replaceAll(oldSceneName,newSceneName);
             try {
             try {
                 com.fdkankan.ucenter.util.FileUtil.writeFile(localPath,newJson);
                 com.fdkankan.ucenter.util.FileUtil.writeFile(localPath,newJson);
+                if("v3".equals(sceneVersion)){
+                    String sceneJsonPath = String.format(SceneResourcePath.dataPath+"/scene.json", newNum);
+                    fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
+                }
+                if("v4".equals(sceneVersion)){
+                    String sceneJsonPath = String.format(SceneResourcePath.DATA_VIEW_PATH+"/scene.json", newNum);
+                    fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
+                }
             }catch (Exception e){
             }catch (Exception e){
                 log.error("writeFile-error:{}",e);
                 log.error("writeFile-error:{}",e);
+            }finally {
+                FileUtil.del(localPath);
             }
             }
-            if("v3".equals(sceneVersion)){
-                String sceneJsonPath = String.format(SceneResourcePath.dataPath+"/scene.json", newNum);
-                fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
-            }
-            if("v4".equals(sceneVersion)){
-                String sceneJsonPath = String.format(SceneResourcePath.DATA_VIEW_PATH+"/scene.json", newNum);
-                fYunFileServiceInterface.uploadFile(localPath, sceneJsonPath);
-            }
+
         }
         }
 
 
     }
     }
@@ -168,7 +170,7 @@ public class SceneCommonService {
         String localPath = SceneResourcePath.nasBasePath + ossStatusJsonPath;
         String localPath = SceneResourcePath.nasBasePath + ossStatusJsonPath;
         File file = new File(localPath);
         File file = new File(localPath);
         if(!file.getParentFile().exists()){
         if(!file.getParentFile().exists()){
-            file.mkdirs();
+            file.getParentFile().mkdirs();
         }
         }
         String fileContent = fYunFileServiceInterface.getFileContent(ossStatusJsonPath);
         String fileContent = fYunFileServiceInterface.getFileContent(ossStatusJsonPath);
         if(StringUtils.isNotBlank(fileContent)){
         if(StringUtils.isNotBlank(fileContent)){
@@ -178,6 +180,8 @@ public class SceneCommonService {
                 fYunFileServiceInterface.uploadFile(localPath,ossStatusJsonPath);
                 fYunFileServiceInterface.uploadFile(localPath,ossStatusJsonPath);
             }catch (Exception e){
             }catch (Exception e){
                 log.error("writeFile-error:{}",e);
                 log.error("writeFile-error:{}",e);
+            }finally {
+                FileUtil.del(localPath);
             }
             }
         }
         }