mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix VFS FullPath errors
This commit is contained in:
parent
8efdfcd5f0
commit
fee49cca12
@ -250,7 +250,14 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
public async Task BackfillMissing()
|
public async Task BackfillMissing()
|
||||||
{
|
{
|
||||||
var newFiles = _knownArchives.ToDictionary(kv => kv.Key,
|
var newFiles = _knownArchives.ToDictionary(kv => kv.Key,
|
||||||
kv => new VirtualFile {Name = kv.Value, Size = kv.Value.Size, Hash = kv.Key});
|
kv => new VirtualFile
|
||||||
|
{
|
||||||
|
Name = kv.Value,
|
||||||
|
Size = kv.Value.Size,
|
||||||
|
Hash = kv.Key,
|
||||||
|
});
|
||||||
|
|
||||||
|
newFiles.Values.Do(f => f.FillFullPath(0));
|
||||||
|
|
||||||
var parentchild = new Dictionary<(VirtualFile, RelativePath), VirtualFile>();
|
var parentchild = new Dictionary<(VirtualFile, RelativePath), VirtualFile>();
|
||||||
|
|
||||||
@ -266,6 +273,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
var nf = new VirtualFile {Name = path, Parent = parent};
|
var nf = new VirtualFile {Name = path, Parent = parent};
|
||||||
|
nf.FillFullPath();
|
||||||
parent.Children = parent.Children.Add(nf);
|
parent.Children = parent.Children.Add(nf);
|
||||||
parentchild.Add((parent, path), nf);
|
parentchild.Add((parent, path), nf);
|
||||||
parent = nf;
|
parent = nf;
|
||||||
|
@ -153,6 +153,8 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
LastAnalyzed = DateTime.Now.AsUnixTime(),
|
LastAnalyzed = DateTime.Now.AsUnixTime(),
|
||||||
Hash = file.Hash
|
Hash = file.Hash
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vself.FillFullPath();
|
||||||
|
|
||||||
vself.Children = file.Children.Select(f => Convert(f, f.Name, vself)).ToImmutableList();
|
vself.Children = file.Children.Select(f => Convert(f, f.Name, vself)).ToImmutableList();
|
||||||
|
|
||||||
@ -192,11 +194,24 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillFullPath(in int depth)
|
internal void FillFullPath()
|
||||||
|
{
|
||||||
|
int depth = 0;
|
||||||
|
var self = this;
|
||||||
|
while (self.Parent != null)
|
||||||
|
{
|
||||||
|
depth += 1;
|
||||||
|
self = self.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
FillFullPath(depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void FillFullPath(int depth)
|
||||||
{
|
{
|
||||||
if (depth == 0)
|
if (depth == 0)
|
||||||
{
|
{
|
||||||
FullPath = new FullPath((AbsolutePath)Name, new RelativePath[0]);
|
FullPath = new FullPath((AbsolutePath)Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -333,27 +348,25 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
public static ExtendedHashes FromFile(IExtractedFile file)
|
public static ExtendedHashes FromFile(IExtractedFile file)
|
||||||
{
|
{
|
||||||
var hashes = new ExtendedHashes();
|
var hashes = new ExtendedHashes();
|
||||||
using (var stream = file.OpenRead())
|
using var stream = file.OpenRead();
|
||||||
|
hashes.SHA256 = System.Security.Cryptography.SHA256.Create().ComputeHash(stream).ToHex();
|
||||||
|
stream.Position = 0;
|
||||||
|
hashes.SHA1 = System.Security.Cryptography.SHA1.Create().ComputeHash(stream).ToHex();
|
||||||
|
stream.Position = 0;
|
||||||
|
hashes.MD5 = System.Security.Cryptography.MD5.Create().ComputeHash(stream).ToHex();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var bytes = new byte[1024 * 8];
|
||||||
|
var crc = new Crc32();
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
hashes.SHA256 = System.Security.Cryptography.SHA256.Create().ComputeHash(stream).ToHex();
|
var read = stream.Read(bytes, 0, bytes.Length);
|
||||||
stream.Position = 0;
|
if (read == 0) break;
|
||||||
hashes.SHA1 = System.Security.Cryptography.SHA1.Create().ComputeHash(stream).ToHex();
|
crc.Update(bytes, 0, read);
|
||||||
stream.Position = 0;
|
|
||||||
hashes.MD5 = System.Security.Cryptography.MD5.Create().ComputeHash(stream).ToHex();
|
|
||||||
stream.Position = 0;
|
|
||||||
|
|
||||||
var bytes = new byte[1024 * 8];
|
|
||||||
var crc = new Crc32();
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var read = stream.Read(bytes, 0, bytes.Length);
|
|
||||||
if (read == 0) break;
|
|
||||||
crc.Update(bytes, 0, read);
|
|
||||||
}
|
|
||||||
|
|
||||||
hashes.CRC = crc.DigestBytes().ToHex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hashes.CRC = crc.DigestBytes().ToHex();
|
||||||
|
|
||||||
return hashes;
|
return hashes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user