Browse Source

每次下载必更新文件类型

master
Fangjie Hu 8 years ago
parent
commit
c68b4ee0b7
  1. 33
      designer_base/src/com/fr/design/extra/PluginHelper.java

33
designer_base/src/com/fr/design/extra/PluginHelper.java

@ -140,6 +140,14 @@ public class PluginHelper {
List<PluginDependenceUnit> list = dependence.getDependPlugins(); List<PluginDependenceUnit> list = dependence.getDependPlugins();
for (int i = 0;list != null && i < list.size(); i++){ for (int i = 0;list != null && i < list.size(); i++){
PluginDependenceUnit dependenceUnit = list.get(i); PluginDependenceUnit dependenceUnit = list.get(i);
//覆盖型依赖,立即下载安装
if (dependenceUnit.isCover()){
try {
installCoverDependence(dependenceUnit);
} catch (Exception e) {
throw new PluginDependenceException();
}
}
if (!dependenceUnit.checkFileEnv()){ if (!dependenceUnit.checkFileEnv()){
needInstallDependence.add(dependenceUnit); needInstallDependence.add(dependenceUnit);
} }
@ -153,6 +161,31 @@ public class PluginHelper {
installDependenceOnline(currentID, needInstallDependence); installDependenceOnline(currentID, needInstallDependence);
} }
public static void installCoverDependence(PluginDependenceUnit dependenceUnit) throws Exception {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID()));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream reader = httpClient.getResponseStream();
String temp = StableUtils.pathJoin(PluginHelper.DEPENDENCE_DOWNLOAD_PATH, PluginHelper.TEMP_FILE);
StableUtils.makesureFileExist(new File(temp));
FileOutputStream writer = new FileOutputStream(temp);
byte[] buffer = new byte[PluginConstants.BYTES_NUM];
int bytesRead = 0;
while ((bytesRead = reader.read(buffer)) > 0) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[PluginConstants.BYTES_NUM];
}
reader.close();
writer.flush();
writer.close();
//安装文件
IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir());
}else {
throw new PluginDependenceException();
}
}
/** /**
* 构造一个下载UI * 构造一个下载UI

Loading…
Cancel
Save