Skip to content

Commit

Permalink
Fix shadow copy up to date check on startup (#52831)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanConroy committed May 10, 2024
1 parent e3e668f commit bf8d6b6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ bool Environment::CheckUpToDate(const std::wstring& source, const std::filesyste
auto sourceInnerDirectory = std::filesystem::directory_entry(path);
if (sourceInnerDirectory.path() != directoryToIgnore)
{
CheckUpToDate(destination / path.path().filename(), path.path(), extension, directoryToIgnore);
CheckUpToDate(/* source */ path.path(), /* destination */ destination / path.path().filename(), extension, directoryToIgnore);
}
}
}
Expand Down
35 changes: 32 additions & 3 deletions src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.InternalTesting;
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
using Microsoft.AspNetCore.Testing;
using Xunit;
Expand Down Expand Up @@ -142,6 +140,37 @@ public async Task ShadowCopySingleFileChangedWorks()
Assert.True(response.IsSuccessStatusCode);
}

[ConditionalFact]
public async Task ShadowCopyDeleteFolderDuringShutdownWorks()
{
using var directory = TempDirectory.Create();
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
deploymentParameters.HandlerSettings["enableShadowCopy"] = "true";
deploymentParameters.HandlerSettings["shadowCopyDirectory"] = directory.DirectoryPath;

var deploymentResult = await DeployAsync(deploymentParameters);
var deleteDirPath = Path.Combine(deploymentResult.ContentRoot, "wwwroot/deletethis");
Directory.CreateDirectory(deleteDirPath);
File.WriteAllText(Path.Combine(deleteDirPath, "file.dll"), "");

var response = await deploymentResult.HttpClient.GetAsync("Wow!");
Assert.True(response.IsSuccessStatusCode);

AddAppOffline(deploymentResult.ContentRoot);
await AssertAppOffline(deploymentResult);

// Delete folder + file after app is shut down
// Testing specific path on startup where we compare the app directory contents with the shadow copy directory
Directory.Delete(deleteDirPath, recursive: true);

RemoveAppOffline(deploymentResult.ContentRoot);

await deploymentResult.AssertRecycledAsync();

response = await deploymentResult.HttpClient.GetAsync("Wow!");
Assert.True(response.IsSuccessStatusCode);
}

[ConditionalFact]
public async Task ShadowCopyE2EWorksWithFolderPresent()
{
Expand Down

0 comments on commit bf8d6b6

Please sign in to comment.