potential mcdf fixes

This commit is contained in:
rootdarkarchon
2023-12-17 18:53:22 +01:00
committed by Loporrit
parent c843af1470
commit add2d2eda9
4 changed files with 62 additions and 24 deletions

View File

@@ -33,18 +33,23 @@ public record MareCharaFileData
if (dto.FileReplacements.TryGetValue(ObjectKind.Player, out var fileReplacements))
{
foreach (var file in fileReplacements)
var grouped = fileReplacements.GroupBy(f => f.Hash, StringComparer.OrdinalIgnoreCase);
foreach (var file in grouped)
{
if (!string.IsNullOrEmpty(file.FileSwapPath))
if (string.IsNullOrEmpty(file.Key))
{
FileSwaps.Add(new FileSwap(file.GamePaths, file.FileSwapPath));
foreach (var item in file)
{
FileSwaps.Add(new FileSwap(item.GamePaths, item.FileSwapPath));
}
}
else
{
var filePath = manager.GetFileCacheByHash(file.Hash)?.ResolvedFilepath;
var filePath = manager.GetFileCacheByHash(file.First().Hash)?.ResolvedFilepath;
if (filePath != null)
{
Files.Add(new FileData(file.GamePaths, new FileInfo(filePath).Length));
Files.Add(new FileData(file.SelectMany(f => f.GamePaths), (int)new FileInfo(filePath).Length, file.First().Hash));
}
}
}
@@ -63,5 +68,5 @@ public record MareCharaFileData
public record FileSwap(IEnumerable<string> GamePaths, string FileSwapPath);
public record FileData(IEnumerable<string> GamePaths, long Length);
public record FileData(IEnumerable<string> GamePaths, int Length, string Hash);
}