Skip to content

Commit

Permalink
Fixed #39
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghongxun committed Mar 1, 2016
1 parent dfc6e91 commit 3ba75d2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion HMCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (buildnumber == null)

def versionroot = System.getenv("VERSION_ROOT")
if (versionroot == null)
versionroot = "2.4.0"
versionroot = "2.4.1"

String mavenGroupId = 'HMCL'
String mavenVersion = versionroot + '.' + buildnumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,33 @@ public boolean refreshAssetsIndex(String id) {
MinecraftVersion mv = service.version().getVersionById(id);
if (mv == null)
return false;
return downloadMinecraftAssetsIndex(mv.getAssetsIndex());
return downloadMinecraftAssetsIndexAsync(mv.getAssetsIndex());
}

@Override
public boolean downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assets) {
File assetsLocation = getAssets();
if (!assetsLocation.exists() && !assetsLocation.mkdirs())
HMCLog.warn("Failed to make directories: " + assetsLocation);
File assetsIndex = new File(assetsLocation, "indexes/" + assets.getId() + ".json");
File renamed = null;
if (assetsIndex.exists()) {
renamed = new File(assetsLocation, "indexes/" + assets.getId() + "-renamed.json");
if (assetsIndex.renameTo(renamed))
HMCLog.warn("Failed to rename " + assetsIndex + " to " + renamed);
}
if (new FileDownloadTask(assets.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assets.sha1).setTag(assets.getId() + ".json").run()) {
if (renamed != null && !renamed.delete())
HMCLog.warn("Failed to delete " + renamed + ", maybe you should do it.");
return true;
}
if (renamed != null && !renamed.renameTo(assetsIndex))
HMCLog.warn("Failed to rename " + renamed + " to " + assetsIndex);
return false;
}

@Override
public boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assets) {
File assetsLocation = getAssets();
if (!assetsLocation.exists() && !assetsLocation.mkdirs())
HMCLog.warn("Failed to make directories: " + assetsLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public IMinecraftAssetService(IMinecraftService service) {
*/
public abstract boolean refreshAssetsIndex(String a);

public abstract boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assetsId);

public abstract boolean downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assetsId);

public abstract File getAssetObject(String assetVersion, String name) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
put("AWTError", "");
put("JFileChooser", "Has your operating system been installed completely or is a ghost system? ");
put("JceSecurityManager", "Has your operating system been installed completely or is a ghost system? ");
put("couldn't create component peer", "Fucking computer!");
put("sun.awt.shell.Win32ShellFolder2", "crash.user_fault");
put("UnsatisfiedLinkError", "crash.user_fault");
put("java.awt.HeadlessException", "crash.headless");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void abort() {
while (!in.isEmpty())
synchronized (in) {
Invoker it = in.iterator().next();
if (!it.task.abort())
if (!it.task.abort() && futures.get(it) != null)
futures.get(it).cancel(true);
in.remove(it);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,15 @@ public void executeTask() throws Throwable {
this.url = IOUtils.parseURL(p.getResult());

for (int repeat = 0; repeat < 6; repeat++) {
if (repeat > 0) {
HMCLog.warn("Failed to download, repeat: " + repeat);
if (repeat > 0)
if (failedCallbackReturnsNewURL != null) {
URL tmp = IOUtils.parseURL(failedCallbackReturnsNewURL.apply(repeat));
if (tmp != null) {
url = tmp;
HMCLog.warn("Switch to: " + url);
}
}
}
HMCLog.log("Downloading: " + url + ", to: " + filePath);
if (!shouldContinue)
break;
try {
Expand Down

0 comments on commit 3ba75d2

Please sign in to comment.