فهرست منبع

http客户端超时改为10分钟;解决下载文件资源时key也被纠正的bug;进度百分比精确到两位小数

cuixubin 4 سال پیش
والد
کامیت
6700b906ac

+ 2 - 4
src/main/java/com/persagy/filemove/dto/WorkerFactory.java

@@ -96,13 +96,11 @@ public class WorkerFactory {
                             String resourceKey = null;
                             for(String objId : obj_key.keySet()) {
                                 resourceKey = obj_key.get(objId);
-                                if(SagaFileMoveApp.dto.keyModify.getValue() && resourceKey != null && resourceKey.contains("/")) {
-                                    resourceKey = resourceKey.substring(resourceKey.lastIndexOf("/") + 1);
-                                }
+
                                 SagaFileMoveService.fileMove(objId, resourceKey, noFileSet, nullKeySet, moveErrorSet);
                                 System.out.println("--- " + movedNum);
                                 updateProgress(++movedNum, totalNum);
-                                updateTitle(String.format("%.1f", 100.0 * movedNum / totalNum)+"%");
+                                updateTitle(String.format("%.2f", 100.0 * movedNum / totalNum)+"%");
                             }
 
                             int noFileNum = noFileSet.size(), nullKeyNum = nullKeySet.size(), moveErrNum = moveErrorSet.size();

+ 4 - 1
src/main/java/com/persagy/filemove/service/SagaFileMoveService.java

@@ -104,7 +104,6 @@ public class SagaFileMoveService {
         byte[] resourceByteData = null;
 
         try {
-            Thread.sleep(3000);
             resourceByteData = HttpTools.httpGetFile(getImgUrl);
         }catch (Exception e) {
             e.printStackTrace();
@@ -140,6 +139,10 @@ public class SagaFileMoveService {
      * @return
      */
     private static String buildUploadResourceUrl(String key) {
+        if(SagaFileMoveApp.dto.keyModify.getValue() && key.contains("/")) {
+            key = key.substring(key.lastIndexOf("/") + 1);
+        }
+
         // 默认使用file_upload上传文件
         String toImgApi = "file";
         if("image".equals(SagaFileMoveApp.dto.imgToApiType.getValue())) {

+ 3 - 3
src/main/java/com/persagy/filemove/util/HttpTools.java

@@ -38,11 +38,11 @@ public class HttpTools {
 		CONNECTION_MANAGER.setDefaultMaxPerRoute(50);
 		RequestConfig requestConfig = RequestConfig.custom()
 				// 与远程主机连接建立时间,三次握手完成时间
-				.setConnectTimeout(5000)
+				.setConnectTimeout(60000)
 				// 建立连接后,数据包传输过程中,两个数据包之间间隔的最大时间
-				.setSocketTimeout(10000)
+				.setSocketTimeout(600000)
 				// httpClient使用连接池来管理连接,这个时间就是从连接池获取连接的超时时间
-				.setConnectionRequestTimeout(5000).build();
+				.setConnectionRequestTimeout(60000).build();
 		HTTP_CLIENT = HttpClients.custom().setConnectionManager(CONNECTION_MANAGER)
 				.setDefaultRequestConfig(requestConfig).build();
 	}