2 Commits

Author SHA1 Message Date
228b3bc55f RemoteCatalog order changed 2024-12-31 21:53:54 +05:00
7882bb9bfd Fix for libraries in modpacks 2024-12-31 21:51:25 +05:00
3 changed files with 20 additions and 4 deletions

View File

@@ -22,8 +22,8 @@ public record Config
public int max_parallel_downloads { get; set; } = 16; public int max_parallel_downloads { get; set; } = 16;
public GameVersionCatalogProps[] version_catalogs { get; set; } = public GameVersionCatalogProps[] version_catalogs { get; set; } =
[ [
new() { name = "Тимериховое", url = "https://timerix.ddns.net/minecraft/catalog.json" },
new() { name = "Mojang", url = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" }, new() { name = "Mojang", url = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" },
new() { name = "Тимериховое", url = "https://timerix.ddns.net/minecraft/catalog.json" }
]; ];

View File

@@ -39,8 +39,6 @@ public class GameVersion
public async Task Download(bool update, Action<NetworkTask> networkTaskCreatedCallback) public async Task Download(bool update, Action<NetworkTask> networkTaskCreatedCallback)
{ {
LauncherApp.Logger.LogInfo(Id, $"started updating version {Id}"); LauncherApp.Logger.LogInfo(Id, $"started updating version {Id}");
List<INetworkTaskFactory> taskFactories = List<INetworkTaskFactory> taskFactories =

View File

@@ -8,11 +8,14 @@ namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories;
public class ModpackDownloadTaskFactory : INetworkTaskFactory public class ModpackDownloadTaskFactory : INetworkTaskFactory
{ {
INetworkTaskFactory _implementationVersion; INetworkTaskFactory _implementationVersion;
private GameVersionDescriptor _descriptor;
public ModpackDownloadTaskFactory(GameVersionDescriptor descriptor) public ModpackDownloadTaskFactory(GameVersionDescriptor descriptor)
{ {
if(descriptor.modpack is null) if(descriptor.modpack is null)
throw new ArgumentNullException(nameof(descriptor.modpack)); throw new ArgumentNullException(nameof(descriptor.modpack));
_descriptor = descriptor;
_implementationVersion = descriptor.modpack.format_version switch _implementationVersion = descriptor.modpack.format_version switch
{ {
1 => new MyModpackV1DownloadTaskFactory(descriptor), 1 => new MyModpackV1DownloadTaskFactory(descriptor),
@@ -22,6 +25,21 @@ public class ModpackDownloadTaskFactory : INetworkTaskFactory
public Task<NetworkTask?> CreateAsync(bool checkHashes) public Task<NetworkTask?> CreateAsync(bool checkHashes)
{ {
// Modpacks can include libraries.
// This libraries are downloaded in launcher_dir/libraries through symbolic link.
var localLibsDir = Path.Concat(PathHelper.GetVersionDir(_descriptor.id), "libraries");
var globalLibsDir = PathHelper.GetLibrariesDir();
var dirInfo = new DirectoryInfo(localLibsDir.ToString());
// delete dir if it isn't symlink
if(dirInfo.Exists && dirInfo.LinkTarget is null)
dirInfo.Delete(true);
if (!dirInfo.Exists)
{
LauncherApp.Logger.LogInfo(nameof(ModpackDownloadTaskFactory),
$"Creating symbolic link '{localLibsDir}' -> '{globalLibsDir}'");
dirInfo.CreateAsSymbolicLink(globalLibsDir.ToString());
}
return _implementationVersion.CreateAsync(checkHashes); return _implementationVersion.CreateAsync(checkHashes);
} }
} }