mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-12 14:14:52 +08:00
Try to fix auto update
This commit is contained in:
parent
17eca9dd2f
commit
4b435d4ac3
@ -161,15 +161,19 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
|
||||
@Override
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Exception {
|
||||
if (!areDependTasksSucceeded) {
|
||||
tempFile.delete();
|
||||
return;
|
||||
}
|
||||
HashMap<String, String> json = new HashMap<>();
|
||||
File f = getSelf(newestVersion);
|
||||
if (!FileUtils.makeDirectory(f.getParentFile()))
|
||||
HMCLog.warn("Failed to make directories: " + f.getParent());
|
||||
throw new IOException("Failed to make directories: " + f.getParent());
|
||||
|
||||
for (int i = 0; f.exists(); i++)
|
||||
f = new File(BASE_FOLDER, "HMCL-" + newestVersion + (i > 0 ? "-" + i : "") + ".jar");
|
||||
if (!f.createNewFile())
|
||||
HMCLog.warn("Failed to create new file: " + f);
|
||||
throw new IOException("Failed to create new file: " + f);
|
||||
|
||||
try (JarOutputStream jos = new JarOutputStream(FileUtils.openOutputStream(f))) {
|
||||
Pack200.newUnpacker().unpack(new GZIPInputStream(FileUtils.openInputStream(tempFile)), jos);
|
||||
|
@ -212,6 +212,7 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
||||
ppl.onProgressProviderDone(this);
|
||||
return;
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
filePath.delete();
|
||||
setFailReason(new IOException(C.i18n("download.failed") + " " + url, e));
|
||||
} finally {
|
||||
closeFiles();
|
||||
|
Loading…
Reference in New Issue
Block a user