feat: Updates to .NET 6 (#843)
* Fixes an issue with moving directories across volumes * Removes usages of WebClient * Removes usages of Cryptographic Providers Note: Even though .NET 6 introduces Xoshiro RNG, there is no way to control the seed. I'll do some reconciliation of Xoshiro so it functions closer to the built in one. For the most part, it has parity though. Benchmarks show there is nothing odd about the implementations, they are within 1ns of each other.
This commit is contained in:
parent
a4d9a3bdc2
commit
c31bf20d0e
35 changed files with 192 additions and 231 deletions
|
|
@ -34,7 +34,7 @@ namespace Server.Json
|
|||
{
|
||||
WriteIndented = true,
|
||||
AllowTrailingCommas = true,
|
||||
IgnoreNullValues = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ namespace Server
|
|||
{
|
||||
private RandomNumberGenerator m_Random;
|
||||
|
||||
public RandomNumberGenerator Generator => m_Random ??= new RNGCryptoServiceProvider();
|
||||
public RandomNumberGenerator Generator => m_Random ??= RandomNumberGenerator.Create();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override ulong NextULong()
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[sizeof(ulong)];
|
||||
Generator.GetBytes(buffer);
|
||||
NextBytes(buffer);
|
||||
return BinaryPrimitives.ReadUInt64BigEndian(buffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,5 +63,24 @@ namespace Server
|
|||
Utility.RandomBytes(bytes);
|
||||
return EnsureDirectory(Path.Combine(basePath, bytes.ToHexString()));
|
||||
}
|
||||
|
||||
public static void CopyDirectory(string sourcePath, string destinationPath, bool recursive = true)
|
||||
{
|
||||
var searchOptions = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
foreach (var file in Directory.EnumerateFiles(sourcePath, "*", searchOptions))
|
||||
{
|
||||
var fi = new FileInfo(file);
|
||||
var relativePath = Path.GetRelativePath(sourcePath, fi.DirectoryName!);
|
||||
var destFolder = Path.Combine(destinationPath, relativePath);
|
||||
EnsureDirectory(destFolder);
|
||||
fi.CopyTo(Path.Combine(destFolder, fi.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public static void MoveDirectory(string sourcePath, string destinationPath)
|
||||
{
|
||||
CopyDirectory(sourcePath, destinationPath);
|
||||
Directory.Delete(sourcePath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ namespace Server
|
|||
try
|
||||
{
|
||||
EventSink.InvokeWorldSavePostSnapshot(SavePath, tempPath);
|
||||
Directory.Move(tempPath, SavePath);
|
||||
PathUtility.MoveDirectory(tempPath, SavePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue