Search in sources :

Example 1 with StreamVersion

use of net.technicpack.autoupdate.io.StreamVersion in project LauncherV3 by TechnicPack.

the class QueryUpdateStream method runTask.

@Override
public void runTask(InstallTasksQueue queue) throws IOException, InterruptedException {
    try {
        StreamVersion version = updateStream.getStreamVersion(relauncher.getStreamName());
        if (version == null || version.getBuild() == 0)
            return;
        for (LauncherResource resource : version.getResources()) {
            IFileVerifier verifier = new MD5FileVerifier(resource.getMd5());
            File downloadFile = new File(new File(directories.getAssetsDirectory(), "launcher"), resource.getFilename());
            if (!downloadFile.exists() || !verifier.isFileValid(downloadFile))
                downloadTasks.addTask(new DownloadFileTask(resource.getUrl(), downloadFile, verifier, resource.getFilename()));
        }
        if (version.getBuild() == relauncher.getCurrentBuild() || (relauncher.getStreamName().startsWith("beta") && version.getBuild() <= relauncher.getCurrentBuild()))
            return;
        String updateUrl = null;
        String runningPath = relauncher.getRunningPath();
        if (runningPath == null) {
            throw new DownloadException("Could not load a running path for currently-executing launcher.");
        }
        if (runningPath.endsWith(".exe"))
            updateUrl = version.getExeUrl();
        else
            updateUrl = version.getJarUrl();
        downloadTasks.addTask(new DownloadUpdate(updateUrl, relauncher, postDownloadTasks));
    } catch (RestfulAPIException ex) {
        return;
    }
}
Also used : LauncherResource(net.technicpack.autoupdate.io.LauncherResource) RestfulAPIException(net.technicpack.rest.RestfulAPIException) DownloadException(net.technicpack.launchercore.exception.DownloadException) IFileVerifier(net.technicpack.launchercore.install.verifiers.IFileVerifier) File(java.io.File) DownloadFileTask(net.technicpack.launchercore.install.tasks.DownloadFileTask) StreamVersion(net.technicpack.autoupdate.io.StreamVersion) MD5FileVerifier(net.technicpack.launchercore.install.verifiers.MD5FileVerifier)

Aggregations

File (java.io.File)1 LauncherResource (net.technicpack.autoupdate.io.LauncherResource)1 StreamVersion (net.technicpack.autoupdate.io.StreamVersion)1 DownloadException (net.technicpack.launchercore.exception.DownloadException)1 DownloadFileTask (net.technicpack.launchercore.install.tasks.DownloadFileTask)1 IFileVerifier (net.technicpack.launchercore.install.verifiers.IFileVerifier)1 MD5FileVerifier (net.technicpack.launchercore.install.verifiers.MD5FileVerifier)1 RestfulAPIException (net.technicpack.rest.RestfulAPIException)1