Rework indexed files to support cases where multiple archives reference the same file, but in different locations

This commit is contained in:
Timothy Baldridge 2020-01-02 07:39:36 -07:00
parent 9074941229
commit e614e6777c
3 changed files with 24 additions and 12 deletions

View File

@ -17,10 +17,15 @@ namespace Wabbajack.CacheServer.DTOs
public string SHA1 { get; set; }
public string MD5 { get; set; }
public string CRC { get; set; }
public string Name { get; set; }
public string Extension { get; set; }
public long Size { get; set; }
public bool IsArchive { get; set; }
public List<string> Children { get; set; } = new List<string>();
public List<ChildFile> Children { get; set; } = new List<ChildFile>();
}
public class ChildFile
{
public string Name;
public string Extension;
public string Hash;
}
}

View File

@ -77,23 +77,30 @@ namespace Wabbajack.CacheServer.Jobs
var name = isTop ? Path.GetFileName(file.Name) : file.Name;
var ifile = new IndexedFile
{
Name = name,
Extension = Path.GetExtension(name),
Hash = file.Hash,
SHA256 = file.ExtendedHashes.SHA256,
SHA1 = file.ExtendedHashes.SHA1,
MD5 = file.ExtendedHashes.MD5,
CRC = file.ExtendedHashes.CRC,
Size = file.Size,
Children = file.Children != null ? file.Children.Select(f =>
{
ConvertArchive(files, f, false);
return f.Hash;
}).ToList() : new List<string>()
Children = file.Children != null ? file.Children.Select(
f =>
{
ConvertArchive(files, f, false);
return new ChildFile
{
Hash = f.Hash,
Name = f.Name.ToLowerInvariant(),
Extension = Path.GetExtension(f.Name.ToLowerInvariant())
};
}).ToList() : new List<ChildFile>()
};
ifile.IsArchive = ifile.Children.Count > 0;
files.Add(ifile);
return files;
}
}
}

View File

@ -142,7 +142,7 @@ namespace Wabbajack.CacheServer
return response;
}
private async Task<object> HandleFileID(dynamic arg)
private async Task<Response> HandleFileID(dynamic arg)
{
Utils.Log($"{DateTime.Now} - File Info - {arg.GameName}/{arg.ModID}/{arg.FileID}");
string gameName = arg.GameName;
@ -183,7 +183,7 @@ namespace Wabbajack.CacheServer
return response;
}
private async Task<object> HandleGetFiles(dynamic arg)
private async Task<Response> HandleGetFiles(dynamic arg)
{
Utils.Log($"{DateTime.Now} - Mod Files - {arg.GameName} {arg.ModID}");
string gameName = arg.GameName;