Skip to content

Commit

Permalink
Comments for what's happening when installing bundled mods
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Oct 9, 2024
1 parent bae0cc8 commit b67c99b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/NexusMods.Collections/InstallCollectionJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,17 @@ await Parallel.ForEachAsync(toInstall, context.CancellationToken, async (file, _

private async Task<LoadoutItemGroup.ReadOnly> InstallBundledMod(LoadoutId loadoutId, Mod fileMod, LoadoutItemGroup.ReadOnly group, LibraryArchive.ReadOnly collectionArchive)
{
// Bundled mods are found inside the collection archive, so we'll have to find the files that are prefixed with the mod's source file expression.
var prefixPath = "bundled".ToRelativePath().Join(fileMod.Source.FileExpression);
// These are the files to install
var prefixFiles = collectionArchive.Children.Where(f => f.Path.InFolder(prefixPath)).ToArray();

using var tx = Connection.BeginTransaction();

if (!collectionArchive.AsLibraryFile().TryGetAsNexusModsCollectionLibraryFile(out var collectionFile))
throw new InvalidOperationException("The source collection is not a NexusModsCollectionLibraryFile.");

// Create the mod group
var modGroup = new NexusCollectionBundledLoadoutGroup.New(tx, out var id)
{
CollectionLibraryFileId = collectionFile,
Expand All @@ -175,7 +178,10 @@ await Parallel.ForEachAsync(toInstall, context.CancellationToken, async (file, _

foreach (var file in prefixFiles)
{
// Remove the prefix path from the file path
var fixedPath = file.Path.RelativeTo(prefixPath);

// Fill out the rest of the file information
_ = new LoadoutFile.New(tx, out var fileId)
{
Hash = file.AsLibraryFile().Hash,
Expand Down

0 comments on commit b67c99b

Please sign in to comment.