Search in sources :

Example 11 with DownloadException

use of net.technicpack.launchercore.exception.DownloadException 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

DownloadException (net.technicpack.launchercore.exception.DownloadException)11 File (java.io.File)5 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)4 IFileVerifier (net.technicpack.launchercore.install.verifiers.IFileVerifier)3 InstallTasksQueue (net.technicpack.launchercore.install.InstallTasksQueue)2 DownloadFileTask (net.technicpack.launchercore.install.tasks.DownloadFileTask)2 EnsureFileTask (net.technicpack.launchercore.install.tasks.EnsureFileTask)2 SHA1FileVerifier (net.technicpack.launchercore.install.verifiers.SHA1FileVerifier)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 IOException (java.io.IOException)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 ClosedByInterruptException (java.nio.channels.ClosedByInterruptException)1 OverlappingFileLockException (java.nio.channels.OverlappingFileLockException)1 ReadableByteChannel (java.nio.channels.ReadableByteChannel)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1