mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-06-06 14:27:01 +03:00
[FIX][EXPERIMENTAL] Full support UpdatesProvider
This commit is contained in:
parent
e664c579a5
commit
c65e20d77b
5 changed files with 41 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.base.Launcher;
|
import pro.gravit.launcher.base.Launcher;
|
||||||
import pro.gravit.launcher.base.Downloader;
|
import pro.gravit.launcher.base.Downloader;
|
||||||
|
import pro.gravit.launcher.core.hasher.HashedDir;
|
||||||
import pro.gravit.launchserver.HttpRequester;
|
import pro.gravit.launchserver.HttpRequester;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.command.Command;
|
import pro.gravit.launchserver.command.Command;
|
||||||
|
@ -46,6 +47,10 @@ public void invoke(String... args) throws Exception {
|
||||||
String type = args.length > 2 ? args[2] : "mojang";
|
String type = args.length > 2 ? args[2] : "mojang";
|
||||||
Path assetDir = server.createTempDirectory("assets");
|
Path assetDir = server.createTempDirectory("assets");
|
||||||
var updatesDir = server.config.updatesProvider.getUpdatesDir(dirName);
|
var updatesDir = server.config.updatesProvider.getUpdatesDir(dirName);
|
||||||
|
if(updatesDir == null) {
|
||||||
|
updatesDir = new HashedDir();
|
||||||
|
server.config.updatesProvider.create(dirName);
|
||||||
|
}
|
||||||
|
|
||||||
// Create asset dir
|
// Create asset dir
|
||||||
if (Files.notExists(assetDir)) {
|
if (Files.notExists(assetDir)) {
|
||||||
|
@ -92,7 +97,7 @@ public void invoke(String... args) throws Exception {
|
||||||
hash = hash.substring(0, 2) + "/" + hash;
|
hash = hash.substring(0, 2) + "/" + hash;
|
||||||
var size = value.get("size").getAsLong();
|
var size = value.get("size").getAsLong();
|
||||||
var path = "objects/" + hash;
|
var path = "objects/" + hash;
|
||||||
if (updatesDir.findRecursive(path).isFound()) {
|
if (updatesDir.tryFindRecursive(path).isFound()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
toDownload.add(new Downloader.SizedFile(hash, path, size));
|
toDownload.add(new Downloader.SizedFile(hash, path, size));
|
||||||
|
|
|
@ -43,6 +43,7 @@ public void invoke(String... args) throws IOException, CommandException {
|
||||||
String versionName = args[0];
|
String versionName = args[0];
|
||||||
String dirName = IOHelper.verifyFileName(args[1] != null ? args[1] : args[0]);
|
String dirName = IOHelper.verifyFileName(args[1] != null ? args[1] : args[0]);
|
||||||
Path clientDir = server.createTempDirectory("client");
|
Path clientDir = server.createTempDirectory("client");
|
||||||
|
server.config.updatesProvider.create(dirName);
|
||||||
|
|
||||||
boolean isMirrorClientDownload = false;
|
boolean isMirrorClientDownload = false;
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import pro.gravit.launcher.core.hasher.HashedDir;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.command.Command;
|
import pro.gravit.launchserver.command.Command;
|
||||||
import pro.gravit.utils.command.CommandException;
|
import pro.gravit.utils.command.CommandException;
|
||||||
|
@ -41,6 +42,9 @@ public void invoke(String... args) throws Exception {
|
||||||
String indexFileName = IOHelper.verifyFileName(args[1]);
|
String indexFileName = IOHelper.verifyFileName(args[1]);
|
||||||
String outputAssetDirName = IOHelper.verifyFileName(args[2]);
|
String outputAssetDirName = IOHelper.verifyFileName(args[2]);
|
||||||
var updatesDir = server.config.updatesProvider.getUpdatesDir(inputAssetDirName);
|
var updatesDir = server.config.updatesProvider.getUpdatesDir(inputAssetDirName);
|
||||||
|
if(updatesDir == null) {
|
||||||
|
server.config.updatesProvider.create(inputAssetDirName);
|
||||||
|
}
|
||||||
Path outputAssetDir = Path.of(outputAssetDirName);
|
Path outputAssetDir = Path.of(outputAssetDirName);
|
||||||
|
|
||||||
// Create new asset dir
|
// Create new asset dir
|
||||||
|
|
|
@ -95,6 +95,35 @@ public FindRecursiveResult findRecursive(String path) {
|
||||||
return new FindRecursiveResult(current, entry, name);
|
return new FindRecursiveResult(current, entry, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FindRecursiveResult tryFindRecursive(String path) {
|
||||||
|
StringTokenizer t = new StringTokenizer(path, "/");
|
||||||
|
HashedDir current = this;
|
||||||
|
HashedEntry entry = null;
|
||||||
|
String name = null;
|
||||||
|
while (t.hasMoreTokens()) {
|
||||||
|
name = t.nextToken();
|
||||||
|
HashedEntry e = current.map.get(name);
|
||||||
|
if (e == null && !t.hasMoreTokens()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (e == null) {
|
||||||
|
return new FindRecursiveResult(current, entry, name);
|
||||||
|
}
|
||||||
|
if (e.getType() == Type.DIR) {
|
||||||
|
if (!t.hasMoreTokens()) {
|
||||||
|
entry = e;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
current = ((HashedDir) e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entry = e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new FindRecursiveResult(current, entry, name);
|
||||||
|
}
|
||||||
|
|
||||||
public HashedEntry getEntry(String name) {
|
public HashedEntry getEntry(String name) {
|
||||||
return map.get(name);
|
return map.get(name);
|
||||||
}
|
}
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit 287d0b83b3c71fc7146e2b1cba7bc1760629ade1
|
Subproject commit 38788df61f8efc5453fe9c05017b629648b5fe6f
|
Loading…
Reference in a new issue