Browse Source

Merge pull request #916 in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit '3b4ef22c272c62f2ba3e95b74e63e1283009244f':
  update
  REPORT-17422 && REPORT-17460 更新升级 有jar包没更新
  REPORT-16567 添加台版教学视频链接
bugfix/10.0
Hades 6 years ago
parent
commit
8e7d4ed64d
  1. 39
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

39
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -22,6 +22,7 @@ import com.fr.design.update.ui.widget.UpdateInfoTableCellRender;
import com.fr.design.update.ui.widget.UpdateInfoTableModel; import com.fr.design.update.ui.widget.UpdateInfoTableModel;
import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender; import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils; import com.fr.general.DateUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
@ -29,6 +30,7 @@ import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -37,6 +39,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.sun.java.swing.plaf.motif.MotifProgressBarUI; import com.sun.java.swing.plaf.motif.MotifProgressBarUI;
@ -371,9 +374,7 @@ public class UpdateMainDialog extends UIDialog {
new SwingWorker<JSONObject, Void>() { new SwingWorker<JSONObject, Void>() {
@Override @Override
protected JSONObject doInBackground() throws Exception { protected JSONObject doInBackground() throws Exception {
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("jar10.update")); return new JSONObject(HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update")));
hc.setTimeout(UpdateConstants.CONNECTION_TIMEOUT);
return new JSONObject(hc.getResponseText());
} }
@Override @Override
@ -620,8 +621,11 @@ public class UpdateMainDialog extends UIDialog {
long downloadSize = jo.optLong("size"); long downloadSize = jo.optLong("size");
if (ComparatorUtils.equals(category, "server")) { if (ComparatorUtils.equals(category, "server")) {
File currentJAR = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, downloadName)); File currentJAR = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, downloadName));
if (currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize)) { String currentMD5 = getCurrentJarMD5(currentJAR);
//假如大小一样的jar包就不要下载了 String downloadMD5 = jo.optString("md5");
boolean exist = currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize) && ComparatorUtils.equals(currentMD5, downloadMD5);
if (exist) {
// 如果jar包存在且MD5值和大小与oss上的一致 不下载
continue; continue;
} }
} }
@ -630,6 +634,31 @@ public class UpdateMainDialog extends UIDialog {
} }
} }
/**
* 获取当前jar的md5
* @param currentJAR
* @return
*/
private String getCurrentJarMD5(File currentJAR) {
String md5 = StringUtils.EMPTY;
FileInputStream input = null;
try {
input = new FileInputStream(currentJAR);
md5 = DigestUtils.md5Hex(input);
} catch (Exception ignore) {
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
return md5;
}
/** /**
* jar包更新按钮监听器 * jar包更新按钮监听器
*/ */

Loading…
Cancel
Save