|
@@ -7,6 +7,7 @@ import cn.hutool.core.date.TimeInterval;
|
|
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.core.util.ZipUtil;
|
|
|
import cn.hutool.http.HttpDownloader;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
@@ -104,6 +105,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
private String v3localPath;
|
|
|
@Value("${path.zip-local}")
|
|
|
private String zipLocalFormat;
|
|
|
+ @Value("${path.source-local}")
|
|
|
+ private String sourceLocal;
|
|
|
@Value("${path.zip-oss}")
|
|
|
private String zipOssFormat;
|
|
|
@Value("${path.zip-root}")
|
|
@@ -298,6 +301,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
|
|
|
try {
|
|
|
|
|
|
+ FileUtil.del(String.format(this.sourceLocal, num, ""));
|
|
|
+
|
|
|
TimeInterval timer = DateUtil.timer();
|
|
|
|
|
|
ScenePro scenePro = sceneProService.getByNum(num);
|
|
@@ -319,7 +324,7 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
if(!zipFile.getParentFile().exists()){
|
|
|
zipFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
- out = new ZipOutputStream(zipFile);
|
|
|
+// out = new ZipOutputStream(zipFile);
|
|
|
|
|
|
int imagesVersion =0;
|
|
|
String resolution = "2k";
|
|
@@ -345,7 +350,9 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
//写入启动命令
|
|
|
this.zipBat(out, num, "v3");
|
|
|
|
|
|
- out.close();
|
|
|
+ ZipUtil.zip(String.format(this.sourceLocal, num, ""), zipPath);
|
|
|
+
|
|
|
+// out.close();
|
|
|
|
|
|
//上传压缩包
|
|
|
String uploadPath = String.format(this.zipOssFormat, num);
|
|
@@ -361,9 +368,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
throw e;
|
|
|
}finally {
|
|
|
if(Objects.nonNull(out)){
|
|
|
- out.close();
|
|
|
//删除本地zip包
|
|
|
- FileUtils.deleteFile(zipPath);
|
|
|
+// FileUtils.deleteFile(zipPath);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -452,9 +458,12 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
}
|
|
|
|
|
|
private void zipLocalFiles(ZipOutputStream out, List<String> localFilePaths, String v3localPath, String num, AtomicInteger count, int total, String version) throws Exception{
|
|
|
+ String sourcePath = String.format(this.sourceLocal, num, this.wwwroot);
|
|
|
+ String localPath = "v4".equals(version) ? this.v4localPath : this.v3localPath;
|
|
|
for (String localFilePath : localFilePaths) {
|
|
|
try (FileInputStream in = new FileInputStream(new File(localFilePath));){
|
|
|
- this.zipInputStream(out, localFilePath.replace(v3localPath, ""), in);
|
|
|
+// this.zipInputStream(out, localFilePath.replace(v3localPath, ""), in);
|
|
|
+ FileUtil.copy(localFilePath, localFilePath.replace(localPath, sourcePath), true);
|
|
|
}catch (Exception e){
|
|
|
throw e;
|
|
|
}
|
|
@@ -464,7 +473,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
num, SceneDownloadProgressStatus.DOWNLOAD_COMPRESSING.code(), null, version);
|
|
|
}
|
|
|
//写入code.txt
|
|
|
- this.zipBytes(out, "code.txt", num.getBytes());
|
|
|
+// this.zipBytes(out, "code.txt", num.getBytes());
|
|
|
+ FileUtil.writeUtf8String(num, String.format(sourceLocal, num, "code.txt"));
|
|
|
}
|
|
|
|
|
|
private void zipBat(ZipOutputStream out, String num, String version) throws Exception{
|
|
@@ -472,7 +482,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
if("v3".equals(version)){
|
|
|
batContent = String.format(this.exeContentV3, num);
|
|
|
}
|
|
|
- this.zipBytes(out, exeName, batContent.getBytes());
|
|
|
+// this.zipBytes(out, exeName, batContent.getBytes());
|
|
|
+ FileUtil.writeUtf8String(batContent, String.format(this.sourceLocal, num, exeName));
|
|
|
|
|
|
//更新进度为90%
|
|
|
this.updateProgress(new BigDecimal("0.9").divide(new BigDecimal("0.8"), 6, BigDecimal.ROUND_HALF_UP), num,
|
|
@@ -555,7 +566,8 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
|
|
|
//访问密码置0
|
|
|
String getInfoKey = root + String.format("data/data%s/", num) + "getInfo.json";
|
|
|
- this.zipBytes(out, getInfoKey, getInfo.toString().getBytes());
|
|
|
+ FileUtil.writeUtf8String(getInfo.toString(), String.format(this.sourceLocal, num, this.wwwroot + getInfoKey));
|
|
|
+// this.zipBytes(out, getInfoKey, getInfo.toString().getBytes());
|
|
|
}
|
|
|
|
|
|
private void processImage(String sceneNum, String key, ZipOutputStream out, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
|
|
@@ -615,9 +627,7 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
continue;
|
|
|
}
|
|
|
imgKeys.add(fky);
|
|
|
- HttpUtil.downloadFile(url, "/home/backend/downloads/scenes/" + sceneNum + "/" + fky);
|
|
|
-// fYunFileService.downloadFile(fky, "/home/backend/downloads/scenes/" + sceneNum + "/" + fky);
|
|
|
-// this.zipBytes(out, wwwroot + fky, FileUtils.getBytesFromUrl(url));
|
|
|
+ HttpUtil.downloadFile(url, String.format(sourceLocal, sceneNum, this.wwwroot + fky));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -642,9 +652,11 @@ public class SceneDownloadHandlerServiceImpl {
|
|
|
.replace("https://spc.html","spc.html")
|
|
|
.replace("https://smobile.html", "smobile.html");
|
|
|
|
|
|
- zipBytes(out, prefix + key, content.getBytes());
|
|
|
+// zipBytes(out, prefix + key, content.getBytes());
|
|
|
+ FileUtil.writeUtf8String(content, String.format(sourceLocal, num, this.wwwroot + prefix + key));
|
|
|
}else{
|
|
|
- zipBytes(out, prefix + key, FileUtils.getBytesFromUrl(url));
|
|
|
+// zipBytes(out, prefix + key, FileUtils.getBytesFromUrl(url));
|
|
|
+ HttpUtil.downloadFile(url, String.format(sourceLocal, num, prefix + key));
|
|
|
}
|
|
|
}
|
|
|
|