Exemplo n.º 1
0
  public void update() {
    String path = null;
    try {
      path =
          new File(LaunchFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath())
              .getCanonicalPath();
      path = URLDecoder.decode(path, "UTF-8");
    } catch (IOException e) {
      Logger.logError("Couldn't get path to current launcher jar/exe", e);
    }
    String temporaryUpdatePath =
        Settings.getSettings().getInstallPath()
            + File.separator
            + "updatetemp"
            + File.separator
            + path.substring(path.lastIndexOf(File.separator) + 1);
    String extension = path.substring(path.lastIndexOf('.') + 1);
    extension = "exe".equalsIgnoreCase(extension) ? extension : "jar";

    try {
      URL updateURL = new URL(downloadUrl.toString() + "." + extension);
      File temporaryUpdate = new File(temporaryUpdatePath);
      temporaryUpdate.getParentFile().mkdir();
      FileUtils.downloadToFile(updateURL, temporaryUpdate);
      SelfUpdate.runUpdate(path, temporaryUpdatePath);
    } catch (MalformedURLException e) {
      Logger.logError("Malformed download URL for launcher update", e);
    } catch (IOException e) {
      Logger.logError("Failed to download launcher update", e);
    }
  }
Exemplo n.º 2
0
 public UpdateChecker(int version) {
   this.version = version;
   loadInfo();
   try {
     FileUtils.delete(new File(Settings.getSettings().getInstallPath(), "updatetemp"));
   } catch (Exception ignored) {
   }
 }