diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp b/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp index 7096cf85b808..c49200ce8d2f 100644 --- a/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp +++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp @@ -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); } } } diff --git a/src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs b/src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs index f4b93e637b33..68dc2e78215b 100644 --- a/src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs +++ b/src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs @@ -142,6 +142,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() {