feat:桌面镜像制作脚本,bug修改
parent
20c98d2d5c
commit
550fda7ce2
|
|
@ -1,6 +1,5 @@
|
|||
package com.unisinsight.torrent.controller;
|
||||
|
||||
import com.unisinsight.torrent.util.BtTorrentUtils;
|
||||
import com.unisinsight.torrent.util.ImageVirtualUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -35,12 +34,21 @@ public class DeskImageController {
|
|||
public Double start(@RequestParam("name") String name) {
|
||||
System.out.println("查询进度");
|
||||
Map<String, Object> resultMap = ImageVirtualUtils.progress(name);
|
||||
if(resultMap.get("process")!=null && (Double)resultMap.get("process") == 100){
|
||||
// String pid = (String) resultMap.get("pid");
|
||||
// ImageVirtualUtils.killProgress(pid);
|
||||
return 100.0;
|
||||
// 使用log打印Map内容
|
||||
if (resultMap != null) {
|
||||
log.info("进度信息详情:");
|
||||
for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
|
||||
log.info(" {} = {} ({})", entry.getKey(), entry.getValue(),
|
||||
entry.getValue() != null ? entry.getValue().getClass().getSimpleName() : "null");
|
||||
}
|
||||
} else {
|
||||
return (Double) resultMap.get("process");
|
||||
log.warn("未获取到进度信息,resultMap为null");
|
||||
}
|
||||
if (resultMap != null && resultMap.get("progress") != null) {
|
||||
//
|
||||
return (Double) resultMap.get("progress");
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.unisinsight.torrent.util;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
|
@ -13,10 +14,11 @@ import java.util.Map;
|
|||
/**
|
||||
* 种子文件工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class ImageVirtualUtils {
|
||||
|
||||
private static final String BT_SCRIPT_PATH = "/deskTest/convert_image.sh";
|
||||
private static final String JSON_PATH = "/deskTest/logs";
|
||||
private static final String JSON_PATH = "/deskTest/logs/";
|
||||
// private static final String JSON_PATH = "D:\\code\\";
|
||||
|
||||
private static final Long WAIT_START_TIME = 8000L;
|
||||
|
|
@ -106,7 +108,7 @@ public class ImageVirtualUtils {
|
|||
|
||||
// 读取文件内容
|
||||
String content = new String(Files.readAllBytes(Paths.get(JSON_PATH+name)));
|
||||
|
||||
log.info("JSON文件内容: {}", content);
|
||||
// 使用Jackson将JSON转换为Map
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.readValue(content, Map.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue