Fix for libraries in modpacks
This commit is contained in:
parent
968ff99987
commit
7882bb9bfd
@ -39,8 +39,6 @@ public class GameVersion
|
||||
|
||||
public async Task Download(bool update, Action<NetworkTask> networkTaskCreatedCallback)
|
||||
{
|
||||
|
||||
|
||||
LauncherApp.Logger.LogInfo(Id, $"started updating version {Id}");
|
||||
|
||||
List<INetworkTaskFactory> taskFactories =
|
||||
|
||||
@ -8,11 +8,14 @@ namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories;
|
||||
public class ModpackDownloadTaskFactory : INetworkTaskFactory
|
||||
{
|
||||
INetworkTaskFactory _implementationVersion;
|
||||
|
||||
private GameVersionDescriptor _descriptor;
|
||||
|
||||
public ModpackDownloadTaskFactory(GameVersionDescriptor descriptor)
|
||||
{
|
||||
if(descriptor.modpack is null)
|
||||
throw new ArgumentNullException(nameof(descriptor.modpack));
|
||||
|
||||
_descriptor = descriptor;
|
||||
_implementationVersion = descriptor.modpack.format_version switch
|
||||
{
|
||||
1 => new MyModpackV1DownloadTaskFactory(descriptor),
|
||||
@ -22,6 +25,21 @@ public class ModpackDownloadTaskFactory : INetworkTaskFactory
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user