|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.RuntimeUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
@@ -13,6 +14,7 @@ import java.io.File;
|
|
|
* @author Xiewj
|
|
|
* @date 2024/1/12
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
public class DownloadUtil {
|
|
|
public final static String WGET_CMD = "wget -t 10 -N -O @out @url";
|
|
|
|
|
@@ -26,17 +28,21 @@ public class DownloadUtil {
|
|
|
file.getParentFile().mkdirs();
|
|
|
}
|
|
|
try {
|
|
|
- if(FileUtil.size(new File(path)) == 0 ){
|
|
|
+ DownloadUtil.downFile(url,path);
|
|
|
+ if(FileUtil.size(new File(path)) == 0){
|
|
|
while (index<=50){
|
|
|
index++;
|
|
|
DownloadUtil.downFile(url,path);
|
|
|
if (FileUtil.size(new File(path))>0){
|
|
|
+ log.info("文件第{}次下载成功:{}", index, path);
|
|
|
return;
|
|
|
}
|
|
|
- ThreadUtil.safeSleep(500);
|
|
|
+ ThreadUtil.safeSleep(200);
|
|
|
|
|
|
// HttpUtil.downloadFileFromUrl(url,path);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ log.info("文件第{}次下载成功:{}", index, path);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw new BusinessException(-1,"下载报错停止,"+url+","+path);
|