Prefer File.Move for DataProtection key creation + Fallback (#10990)

This commit is contained in:
Brennan 2019-06-07 15:32:08 -07:00 committed by GitHub
parent 5918ac7e8c
commit 3259a2c9f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -143,8 +143,17 @@ namespace Microsoft.AspNetCore.DataProtection.Repositories
// Renames are atomic operations on the file systems we support.
_logger.WritingDataToFile(finalFilename);
// Use File.Copy because File.Move on NFS shares has issues in .NET Core 2.0
File.Copy(tempFilename, finalFilename);
try
{
// Prefer the atomic move operation to avoid multi-process startup issues
File.Move(tempFilename, finalFilename);
}
catch (IOException)
{
// Use File.Copy because File.Move on NFS shares has issues in .NET Core 2.0
// See https://github.com/aspnet/AspNetCore/issues/2941 for more context
File.Copy(tempFilename, finalFilename);
}
}
finally
{

View File

@ -48,8 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.DataHandler
Assert.Equal(input, result);
}
[ConditionalFact]
[SkipOnHelix("https://github.com/aspnet/AspNetCore-Internal/issues/1974")]
[Fact]
public void UnprotectWithDifferentPurposeFails()
{
var provider = ServiceProvider.GetRequiredService<IDataProtectionProvider>();