mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix more warnings
This commit is contained in:
parent
6bf098668a
commit
140090cfc4
@ -133,7 +133,7 @@ public class ModListHarness
|
||||
public async Task AddManualDownload(AbsolutePath path)
|
||||
{
|
||||
var toPath = path.FileName.RelativeTo(_downloadPath);
|
||||
await path.CopyToAsync(toPath, true, CancellationToken.None);
|
||||
await path.CopyToAsync(toPath, CancellationToken.None);
|
||||
|
||||
await toPath.WithExtension(Ext.Meta)
|
||||
.WriteAllLinesAsync(new[] {"[General]", $"manualURL={path.FileName}"}, CancellationToken.None);
|
||||
@ -170,7 +170,7 @@ public record Mod(RelativePath Name, AbsolutePath FullPath, ModListHarness Harne
|
||||
public async Task<AbsolutePath> AddFile(AbsolutePath src)
|
||||
{
|
||||
var dest = FullPath.Combine(src.FileName);
|
||||
await src.CopyToAsync(dest, true, CancellationToken.None);
|
||||
await src.CopyToAsync(dest, CancellationToken.None);
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class CompilerSanityTests : IAsyncLifetime
|
||||
{
|
||||
var newPath = file.RelativeTo(_mod.FullPath).RelativeTo(_mod.FullPath.Combine("duplicates"));
|
||||
newPath.Parent.CreateDirectory();
|
||||
await file.CopyToAsync(newPath, true, CancellationToken.None);
|
||||
await file.CopyToAsync(newPath, CancellationToken.None);
|
||||
}
|
||||
|
||||
await CompileAndValidate(5);
|
||||
|
@ -28,7 +28,7 @@ public static class AbsolutePathExtensions
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
var fi = new FileInfo(path);
|
||||
if (fi.IsReadOnly)
|
||||
@ -192,7 +192,7 @@ public static class AbsolutePathExtensions
|
||||
File.Move(srcStr, destStr, overwrite);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
if (retries > 10)
|
||||
throw;
|
||||
@ -202,11 +202,12 @@ public static class AbsolutePathExtensions
|
||||
}
|
||||
}
|
||||
|
||||
public static async ValueTask CopyToAsync(this AbsolutePath src, AbsolutePath dest, bool overwrite,
|
||||
public static async ValueTask CopyToAsync(this AbsolutePath src, AbsolutePath dest,
|
||||
CancellationToken token)
|
||||
{
|
||||
// TODO: Make this async
|
||||
File.Copy(src.ToString(), dest.ToString(), overwrite);
|
||||
await using var inf = src.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
await using var ouf = dest.Open(FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
await inf.CopyToAsync(ouf, token);
|
||||
}
|
||||
|
||||
public static void WriteAllText(this AbsolutePath file, string str)
|
||||
|
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wabbajack.Paths.IO;
|
||||
|
||||
public class TemporaryFileManager : IDisposable
|
||||
public class TemporaryFileManager : IDisposable, IAsyncDisposable
|
||||
{
|
||||
private readonly AbsolutePath _basePath;
|
||||
private readonly bool _deleteOnDispose;
|
||||
@ -24,6 +25,7 @@ public class TemporaryFileManager : IDisposable
|
||||
{
|
||||
if (!_deleteOnDispose) return;
|
||||
for (var retries = 0; retries < 10; retries++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_basePath.DirectoryExists())
|
||||
@ -31,11 +33,32 @@ public class TemporaryFileManager : IDisposable
|
||||
_basePath.DeleteDirectory();
|
||||
return;
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (IOException)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (!_deleteOnDispose) return;
|
||||
for (var retries = 0; retries < 10; retries++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_basePath.DirectoryExists())
|
||||
return;
|
||||
_basePath.DeleteDirectory();
|
||||
return;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TemporaryPath CreateFile(Extension? ext = default, bool deleteOnDispose = true)
|
||||
{
|
||||
@ -51,4 +74,5 @@ public class TemporaryFileManager : IDisposable
|
||||
path.CreateDirectory();
|
||||
return new TemporaryPath(path);
|
||||
}
|
||||
|
||||
}
|
@ -27,8 +27,9 @@ public struct TemporaryPath : IDisposable, IAsyncDisposable
|
||||
return tp.Path;
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
Path.Delete();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user