예제 #1
0
  public File downloadUpdate(LauncherVersion remoteVersion, String format) throws IOException {
    if (remoteVersion.getSource() == null) { // malformed file, or local version
      throw new RuntimeException("Invalid remote version: source is null");
    }

    // check current format

    String remoteURL = remoteVersion.getSource() + format;

    String fileName =
        "mualauncher_" + remoteVersion.getVersion() + "_" + remoteVersion.getBuild() + "-";

    File temporaryFile = File.createTempFile(fileName, format);

    DownloadAdapter downloader = Downloader.create(remoteURL);

    DownloadWindow window = new DownloadWindow(Resources.string("selfupdate_title"));

    downloader.setDownloadListener(window);

    downloader.downloadToFile(temporaryFile);

    window.dispose(); // not needed anymore

    return temporaryFile;
  }
예제 #2
0
  public LauncherVersion fetchRemoteVersion() {
    try {
      String versionJson = Downloader.create(removeVersionURL).downloadToString();

      return LauncherVersion.fromJson(versionJson);
    } catch (Throwable e) {
      Logger.warning("Unable to fetch remote version: %s", e.getMessage());
      e.printStackTrace();
    }

    return null;
  }