mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 19:49:11 +03:00
Compare commits
No commits in common. "9fba637f83e44feb155110e5f49a998c35e544b9" and "63f9f8e21dfc399503f695eadd46089ca7585234" have entirely different histories.
9fba637f83
...
63f9f8e21d
6 changed files with 14 additions and 51 deletions
|
@ -13,7 +13,6 @@
|
||||||
import java.nio.file.DirectoryStream;
|
import java.nio.file.DirectoryStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -131,41 +130,24 @@ public HashedDir getUpdatesDir(String updateName) {
|
||||||
return updatesDirMap.get(updateName);
|
return updatesDirMap.get(updateName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path resolveUpdateName(String updateName) {
|
|
||||||
if(updateName == null) {
|
|
||||||
return Path.of(updatesDir);
|
|
||||||
}
|
|
||||||
return Path.of(updatesDir).resolve(updateName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upload(String updateName, Map<String, Path> files, boolean deleteAfterUpload) throws IOException {
|
public void upload(String updateName, Map<String, Path> files, boolean deleteAfterUpload) throws IOException {
|
||||||
var path = resolveUpdateName(updateName);
|
var path = Path.of(updatesDir).resolve(updateName);
|
||||||
for(var e : files.entrySet()) {
|
for(var e : files.entrySet()) {
|
||||||
var target = path.resolve(e.getKey());
|
var target = path.resolve(e.getKey());
|
||||||
var source = e.getValue();
|
var source = Path.of(e.getKey());
|
||||||
IOHelper.createParentDirs(target);
|
IOHelper.createParentDirs(target);
|
||||||
if(deleteAfterUpload) {
|
if(deleteAfterUpload) {
|
||||||
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(source, target);
|
||||||
} else {
|
} else {
|
||||||
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(source, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Path> download(String updateName, List<String> files) {
|
|
||||||
var path = resolveUpdateName(updateName);
|
|
||||||
Map<String, Path> map = new HashMap<>();
|
|
||||||
for(var e : files) {
|
|
||||||
map.put(e, path.resolve(e));
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String updateName, List<String> files) throws IOException {
|
public void delete(String updateName, List<String> files) throws IOException {
|
||||||
var path = resolveUpdateName(updateName);
|
var path = Path.of(updatesDir).resolve(updateName);
|
||||||
for(var e : files) {
|
for(var e : files) {
|
||||||
var target = path.resolve(e);
|
var target = path.resolve(e);
|
||||||
Files.delete(target);
|
Files.delete(target);
|
||||||
|
@ -174,13 +156,13 @@ public void delete(String updateName, List<String> files) throws IOException {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String updateName) throws IOException {
|
public void delete(String updateName) throws IOException {
|
||||||
var path = resolveUpdateName(updateName);
|
var path = Path.of(updatesDir).resolve(updateName);
|
||||||
IOHelper.deleteDir(path, true);
|
IOHelper.deleteDir(path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(String updateName) throws IOException {
|
public void create(String updateName) throws IOException {
|
||||||
var path = resolveUpdateName(updateName);
|
var path = Path.of(updatesDir).resolve(updateName);
|
||||||
Files.createDirectories(path);
|
Files.createDirectories(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,15 +37,9 @@ public void sync() throws IOException {
|
||||||
|
|
||||||
public abstract void upload(String updateName, Map<String, Path> files, boolean deleteAfterUpload) throws IOException;
|
public abstract void upload(String updateName, Map<String, Path> files, boolean deleteAfterUpload) throws IOException;
|
||||||
|
|
||||||
public abstract Map<String, Path> download(String updateName, List<String> files);
|
|
||||||
|
|
||||||
public abstract void delete(String updateName, List<String> files) throws IOException;
|
public abstract void delete(String updateName, List<String> files) throws IOException;
|
||||||
|
|
||||||
public abstract void delete(String updateName) throws IOException;
|
public abstract void delete(String updateName) throws IOException;
|
||||||
|
|
||||||
public abstract void create(String updateName) throws IOException;
|
public abstract void create(String updateName) throws IOException;
|
||||||
|
|
||||||
public void close() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class LauncherBinary extends BinaryPipeline {
|
public abstract class LauncherBinary extends BinaryPipeline {
|
||||||
|
@ -57,13 +56,9 @@ public void init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean sync() throws IOException {
|
public final boolean sync() throws IOException {
|
||||||
try {
|
boolean exists = exists();
|
||||||
var target = syncBinaryFile.toString();
|
digest = exists ? SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512, IOHelper.read(syncBinaryFile)) : null;
|
||||||
var path = server.config.updatesProvider.download(null, List.of(target)).get(target);
|
|
||||||
digest = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512, IOHelper.read(path));
|
return exists;
|
||||||
return true;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,10 +176,6 @@ public void init(LaunchServer.ReloadType type) {
|
||||||
server.registerObject("profileProvider", profileProvider);
|
server.registerObject("profileProvider", profileProvider);
|
||||||
profileProvider.init(server);
|
profileProvider.init(server);
|
||||||
}
|
}
|
||||||
if(updatesProvider != null) {
|
|
||||||
server.registerObject("updatesProvider", updatesProvider);
|
|
||||||
updatesProvider.init(server);
|
|
||||||
}
|
|
||||||
if (components != null) {
|
if (components != null) {
|
||||||
components.forEach((k, v) -> server.registerObject("component.".concat(k), v));
|
components.forEach((k, v) -> server.registerObject("component.".concat(k), v));
|
||||||
}
|
}
|
||||||
|
@ -224,10 +220,6 @@ public void close(LaunchServer.ReloadType type) {
|
||||||
server.unregisterObject("profileProvider", profileProvider);
|
server.unregisterObject("profileProvider", profileProvider);
|
||||||
profileProvider.close();
|
profileProvider.close();
|
||||||
}
|
}
|
||||||
if(updatesProvider != null) {
|
|
||||||
server.unregisterObject("updatesProvider", updatesProvider);
|
|
||||||
updatesProvider.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JarSignerConf {
|
public static class JarSignerConf {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
client.checkSign = true;
|
client.checkSign = true;
|
||||||
sendResult(new LauncherRequestEvent(false, server.config.netty.launcherURL, createLauncherExtendedToken(), server.config.netty.security.launcherTokenExpire*1000));
|
sendResult(new LauncherRequestEvent(false, server.config.netty.launcherURL, createLauncherExtendedToken(), server.config.netty.security.launcherTokenExpire*1000));
|
||||||
} else {
|
} else {
|
||||||
sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherURL, null, 0));
|
sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherURL, createLauncherExtendedToken(), server.config.netty.security.launcherTokenExpire*1000));
|
||||||
}
|
}
|
||||||
} else if (launcher_type == 2) //EXE
|
} else if (launcher_type == 2) //EXE
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
client.checkSign = true;
|
client.checkSign = true;
|
||||||
sendResult(new LauncherRequestEvent(false, server.config.netty.launcherEXEURL, createLauncherExtendedToken(), server.config.netty.security.launcherTokenExpire*1000));
|
sendResult(new LauncherRequestEvent(false, server.config.netty.launcherEXEURL, createLauncherExtendedToken(), server.config.netty.security.launcherTokenExpire*1000));
|
||||||
} else {
|
} else {
|
||||||
sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherEXEURL, null, 0));
|
sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherEXEURL, createLauncherExtendedToken(), server.config.netty.security.launcherTokenExpire*1000));
|
||||||
}
|
}
|
||||||
} else sendError("Request launcher type error");
|
} else sendError("Request launcher type error");
|
||||||
}
|
}
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit f615855642ebcb69c5bc98c918782b65ca785a74
|
Subproject commit 9127b086a22c01a174e74a5101329500b106de62
|
Loading…
Reference in a new issue