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 f4309c0b98f1..d0e27c8fd68c 100644 --- a/src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs +++ b/src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs @@ -1,12 +1,8 @@ // 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.Server.IIS.FunctionalTests.Utilities; using Microsoft.AspNetCore.InternalTesting; -using Xunit; +using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests; @@ -142,6 +138,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() {