mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #1273 from LostDragonist/less_ram
Reduce memory used by open file streams
This commit is contained in:
commit
53a1e7af74
@ -177,7 +177,7 @@ namespace Wabbajack.Common
|
||||
{
|
||||
if (otherPath.Exists && overwrite)
|
||||
await otherPath.DeleteAsync();
|
||||
|
||||
|
||||
await CopyToAsync(otherPath);
|
||||
await DeleteAsync();
|
||||
return;
|
||||
@ -190,7 +190,7 @@ namespace Wabbajack.Common
|
||||
public RelativePath RelativeTo(AbsolutePath p)
|
||||
{
|
||||
var relPath = Path.GetRelativePath(p._path, _path);
|
||||
if (relPath == _path)
|
||||
if (relPath == _path)
|
||||
throw new ArgumentException($"{_path} is not a subpath of {p._path}");
|
||||
return new RelativePath(relPath);
|
||||
}
|
||||
@ -262,7 +262,7 @@ namespace Wabbajack.Common
|
||||
// ignore, it doesn't exist so why delete it?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
if (!IsFile) return;
|
||||
@ -310,7 +310,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public AbsolutePath Combine(params string[] paths)
|
||||
{
|
||||
|
||||
|
||||
return new AbsolutePath(Path.Combine(paths.Cons(_path).ToArray()));
|
||||
}
|
||||
|
||||
@ -344,9 +344,9 @@ namespace Wabbajack.Common
|
||||
|
||||
public async ValueTask HardLinkIfOversize(AbsolutePath destination)
|
||||
{
|
||||
if (!destination.Parent.Exists)
|
||||
if (!destination.Parent.Exists)
|
||||
destination.Parent.CreateDirectory();
|
||||
|
||||
|
||||
if (Root == destination.Root && Consts.SupportedBSAs.Contains(Extension))
|
||||
{
|
||||
if (HardLinkTo(destination))
|
||||
@ -398,14 +398,14 @@ namespace Wabbajack.Common
|
||||
{
|
||||
var path = _path;
|
||||
return CircuitBreaker.WithAutoRetryAsync<FileStream, IOException>(async () =>
|
||||
File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, bufferSize: 1048576, useAsync: true));
|
||||
File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, bufferSize: 4096, useAsync: true));
|
||||
}
|
||||
|
||||
public ValueTask<FileStream> WriteShared()
|
||||
{
|
||||
var path = _path;
|
||||
return CircuitBreaker.WithAutoRetryAsync<FileStream, IOException>(async () =>
|
||||
File.Open(path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite, bufferSize: 1048576, useAsync: true));
|
||||
File.Open(path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite, bufferSize: 4096, useAsync: true));
|
||||
}
|
||||
|
||||
public async Task CopyDirectoryToAsync(AbsolutePath destination)
|
||||
|
Loading…
Reference in New Issue
Block a user