diff --git a/src/main/java/com/skcraft/launcher/LauncherUtils.java b/src/main/java/com/skcraft/launcher/LauncherUtils.java index 3a18751..9c5bcb5 100644 --- a/src/main/java/com/skcraft/launcher/LauncherUtils.java +++ b/src/main/java/com/skcraft/launcher/LauncherUtils.java @@ -7,13 +7,16 @@ package com.skcraft.launcher; import com.google.common.io.Closer; +import lombok.extern.java.Log; import java.io.*; import java.net.MalformedURLException; import java.net.URL; +import java.util.List; import java.util.Properties; import java.util.regex.Pattern; +@Log public final class LauncherUtils { private static final Pattern absoluteUrlPattern = Pattern.compile("^[A-Za-z0-9\\-]+://.*$"); @@ -70,7 +73,7 @@ public final class LauncherUtils { - public static void interruptibleDelete(File file) throws IOException, InterruptedException { + public static void interruptibleDelete(File file, List failures) throws IOException, InterruptedException { checkInterrupted(); if (file.isDirectory()) { @@ -81,16 +84,22 @@ public final class LauncherUtils { } for (File f : files) { - interruptibleDelete(f); + interruptibleDelete(f, failures); } - file.delete(); + if (!file.delete()) { + log.warning("Failed to delete " + file.getAbsolutePath()); + failures.add(file); + } } else { if (!file.exists()) { throw new FileNotFoundException("Does not exist: " + file); } - file.delete(); + if (!file.delete()) { + log.warning("Failed to delete " + file.getAbsolutePath()); + failures.add(file); + } } } diff --git a/src/main/java/com/skcraft/launcher/update/HardResetter.java b/src/main/java/com/skcraft/launcher/update/HardResetter.java index 354e48a..cd9100a 100644 --- a/src/main/java/com/skcraft/launcher/update/HardResetter.java +++ b/src/main/java/com/skcraft/launcher/update/HardResetter.java @@ -14,6 +14,7 @@ import lombok.NonNull; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.concurrent.Callable; import static com.skcraft.launcher.util.SharedLocale._; @@ -55,7 +56,7 @@ public class HardResetter implements Callable, ProgressObservable { try { if (dir.isDirectory()) { currentDir = dir; - LauncherUtils.interruptibleDelete(dir); + LauncherUtils.interruptibleDelete(dir, new ArrayList()); } } finally { currentDir = null; diff --git a/src/main/java/com/skcraft/launcher/update/Remover.java b/src/main/java/com/skcraft/launcher/update/Remover.java index 55670c8..12f406f 100644 --- a/src/main/java/com/skcraft/launcher/update/Remover.java +++ b/src/main/java/com/skcraft/launcher/update/Remover.java @@ -8,11 +8,15 @@ package com.skcraft.launcher.update; import com.skcraft.concurrency.ProgressObservable; import com.skcraft.launcher.Instance; +import com.skcraft.launcher.LauncherException; import com.skcraft.launcher.LauncherUtils; import com.skcraft.launcher.persistence.Persistence; import lombok.NonNull; +import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.Callable; import static com.skcraft.launcher.LauncherUtils.checkInterrupted; @@ -46,11 +50,18 @@ public class Remover implements Callable, ProgressObservable { Thread.sleep(2000); + List failures = new ArrayList(); + try { - LauncherUtils.interruptibleDelete(instance.getDir()); + LauncherUtils.interruptibleDelete(instance.getDir(), failures); } catch (IOException e) { Thread.sleep(1000); - LauncherUtils.interruptibleDelete(instance.getDir()); + LauncherUtils.interruptibleDelete(instance.getDir(), failures); + } + + if (failures.size() > 0) { + throw new LauncherException(failures.size() + " failed to delete", + _("instanceDeleter.failures", failures.size())); } return instance; diff --git a/src/main/java/com/skcraft/launcher/update/Updater.java b/src/main/java/com/skcraft/launcher/update/Updater.java index deccb77..913ef44 100644 --- a/src/main/java/com/skcraft/launcher/update/Updater.java +++ b/src/main/java/com/skcraft/launcher/update/Updater.java @@ -132,37 +132,54 @@ public class Updater extends BaseUpdater implements Callable, Progress instance.setLocal(true); Persistence.commitAndForget(instance); - // Install package and get the manifests + // Read manifest + log.info("Reading package manifest..."); progress = new DefaultProgress(-1, _("instanceUpdater.readingManifest")); Manifest manifest = installPackage(installer, instance); + + // Read version manifest + log.info("Reading version manifest..."); progress = new DefaultProgress(-1, _("instanceUpdater.readingVersion")); VersionManifest version = readVersionManifest(manifest); - URL url = manifest.getLibrariesUrl(); - if (url != null) { - librarySources.add(url); - } - progress = new DefaultProgress(-1, _("instanceUpdater.buildingDownloadList")); // Install the .jar File jarPath = launcher.getJarPath(version); URL jarSource = launcher.propUrl("jarUrl", version.getId()); + log.info("JAR at " + jarPath.getAbsolutePath() + ", fetched from " + jarSource); installJar(installer, jarPath, jarSource); - // Download libraries and assets + // Download libraries + log.info("Enumerating libraries to download..."); + + URL url = manifest.getLibrariesUrl(); + if (url != null) { + log.info("Added library source: " + url); + librarySources.add(url); + } + + progress = new DefaultProgress(-1, _("instanceUpdater.collectingLibraries")); installLibraries(installer, version, launcher.getLibrariesDir(), librarySources); + + // Download assets + log.info("Enumerating assets to download..."); + progress = new DefaultProgress(-1, _("instanceUpdater.collectingAssets")); installAssets(installer, version, launcher.propUrl("assetsIndexUrl", version.getAssetsIndex()), assetsSources); - progress = ProgressFilter.between(installer.getDownloader(), 0, 0.9); + log.info("Executing download phase..."); + progress = ProgressFilter.between(installer.getDownloader(), 0, 0.98); installer.download(); - progress = ProgressFilter.between(installer, 0.9, 1); + log.info("Executing install phase..."); + progress = ProgressFilter.between(installer, 0.98, 1); installer.execute(); + log.info("Completing..."); complete(); // Update the instance's information + log.info("Writing instance information..."); instance.setVersion(manifest.getVersion()); instance.setUpdatePending(false); instance.setInstalled(true); diff --git a/src/main/resources/com/skcraft/launcher/lang/Launcher.properties b/src/main/resources/com/skcraft/launcher/lang/Launcher.properties index 4ce0bf3..0353364 100644 --- a/src/main/resources/com/skcraft/launcher/lang/Launcher.properties +++ b/src/main/resources/com/skcraft/launcher/lang/Launcher.properties @@ -150,7 +150,12 @@ instanceUpdater.preparingUpdate=Preparing to update... instanceUpdater.readingManifest=Reading package manifest... instanceUpdater.readingVersion=Reading version manifest... instanceUpdater.buildingDownloadList=Collecting files to download... +instanceUpdater.collectingLibraries=Collecting libraries to download... +instanceUpdater.collectingAssets=Collecting assets to download... + instanceDeleter.deleting=Deleting {0}... +instanceDeleter.failures={0} file(s) could not be deleted. + instanceResetter.resetting=Resetting {0}... instanceLoader.loadingLocal=Loading local instances from disk... instanceLoader.checkingRemote=Checking for new modpacks...