Add WriteAllLinesAsync and AppendAllLinesAsync to IoManager
MODIFY
WalletWasabi/Io/DigestableSafeMutexIoManager.cs
WalletWasabi/Io/DigestableSafeMutexIoManager.cs
@@ -72,7 +72,7 @@ namespace WalletWasabi.Io
await WriteOutHashAsync(res.hash);
}
- public async Task AppendAllLinesAsync(IEnumerable<string> lines, CancellationToken cancellationToken = default)
+ public new async Task AppendAllLinesAsync(IEnumerable<string> lines, CancellationToken cancellationToken = default)
{
if (lines is null || !lines.Any())
{

MODIFY
WalletWasabi/Io/IoManager.cs
WalletWasabi/Io/IoManager.cs
@@ -79,6 +79,28 @@ namespace WalletWasabi.Io
return new StreamReader(fs, Encoding.ASCII, detectEncodingFromByteOrderMarks: true, bufferSize: bufferSize, leaveOpen: false);
}
+ public async Task WriteAllLinesAsync(IEnumerable<string> lines, CancellationToken cancellationToken = default)
+ {
+ if (lines is null || !lines.Any())
+ {
+ return;
+ }
+
+ IoHelpers.EnsureContainingDirectoryExists(FilePath);
+
+ await File.WriteAllLinesAsync(FilePath, lines, cancellationToken);
+ }
+
+ public async Task AppendAllLinesAsync(IEnumerable<string> lines, CancellationToken cancellationToken = default)
+ {
+ if (lines is null || !lines.Any())
+ {
+ return;
+ }
+
+ await File.AppendAllLinesAsync(FilePath, lines, cancellationToken);
+ }
+
#endregion IoOperations
}
}

MODIFY
WalletWasabi/Io/SafeMutexIoManager.cs
WalletWasabi/Io/SafeMutexIoManager.cs
@@ -124,7 +124,7 @@ namespace WalletWasabi.Io
return TryGetSafestFileVersion(out _);
}
- public async Task WriteAllLinesAsync(IEnumerable<string> lines, CancellationToken cancellationToken = default)
+ public new async Task WriteAllLinesAsync(IEnumerable<string> lines, CancellationToken cancellationToken = default)
{
if (lines is null || !lines.Any())
{

Add WriteAllLinesAsync and AppendAllLinesAsync to IoManager