fixes #15 - allow non-archive files to be downloaded and installed directly

This commit is contained in:
Timothy Baldridge 2019-09-02 16:02:04 -06:00
parent 41daec2c3b
commit 5d822bc63a
3 changed files with 6 additions and 2 deletions

View File

@ -462,6 +462,9 @@ namespace VFS
/// <returns></returns>
public VirtualFile FileForArchiveHashPath(string[] archiveHashPath)
{
if (archiveHashPath.Length == 1)
return HashIndex[archiveHashPath[0]].First();
var archive = HashIndex[archiveHashPath[0]].Where(a => a.IsArchive).OrderByDescending(a => a.LastModified).First();
string fullPath = archive.FullPath + "|" + String.Join("|", archiveHashPath.Skip(1));
return Lookup(fullPath);

View File

@ -165,7 +165,6 @@ namespace Wabbajack
Info($"Indexing Archives");
IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder)
.Where(f => Consts.SupportedArchives.Contains(Path.GetExtension(f)))
.Where(f => File.Exists(f + ".meta"))
.Select(f => new IndexedArchive()
{
@ -179,7 +178,9 @@ namespace Wabbajack
Info($"Indexing Files");
IndexedFiles = IndexedArchives.PMap(f => { Status($"Finding files in {Path.GetFileName(f.File.FullPath)}");
return VFS.FilesInArchive(f.File); })
.SelectMany(fs => fs)
.Concat(IndexedArchives.Select(f => f.File))
.OrderByDescending(f => f.TopLevelArchive.LastModified)
.GroupBy(f => f.Hash)
.ToDictionary(f => f.Key, f => f.AsEnumerable());

View File

@ -593,7 +593,7 @@ namespace Wabbajack
private void HashArchives()
{
HashedArchives = Directory.EnumerateFiles(DownloadFolder)
.Where(e => Consts.SupportedArchives.Contains(Path.GetExtension(e)))
.Where(e => !e.EndsWith(".sha"))
.PMap(e => (HashArchive(e), e))
.OrderByDescending(e => File.GetLastWriteTime(e.Item2))
.GroupBy(e => e.Item1)