mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] Ошибка на обновление.
This commit is contained in:
parent
22282df126
commit
d210666df2
1 changed files with 10 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
package pro.gravit.launcher.request.update;
|
package pro.gravit.launcher.request.update;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,6 +27,9 @@ public final class LauncherRequest extends Request<LauncherRequestEvent> impleme
|
||||||
public int launcher_type = EXE_BINARY ? 2 : 1;
|
public int launcher_type = EXE_BINARY ? 2 : 1;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public static final Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class);
|
public static final Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class);
|
||||||
|
|
||||||
|
@LauncherAPI
|
||||||
|
public static final Path C_BINARY_PATH = BINARY_PATH.getParent().resolve(IOHelper.getFileName(BINARY_PATH) + ".tmp");
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe");
|
public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe");
|
||||||
|
@ -52,7 +57,11 @@ public static void update(LauncherRequestEvent result) throws IOException {
|
||||||
}*/
|
}*/
|
||||||
try {
|
try {
|
||||||
ListDownloader downloader = new ListDownloader();
|
ListDownloader downloader = new ListDownloader();
|
||||||
downloader.downloadOne(result.url, BINARY_PATH);
|
downloader.downloadOne(result.url, C_BINARY_PATH);
|
||||||
|
try (InputStream in = IOHelper.newInput(C_BINARY_PATH)) {
|
||||||
|
IOHelper.transfer(in, BINARY_PATH);
|
||||||
|
}
|
||||||
|
Files.deleteIfExists(C_BINARY_PATH);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue