Skip to content

Commit bf8d6b6

Browse files
committed
Fix shadow copy up to date check on startup (#52831)
1 parent e3e668f commit bf8d6b6

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool Environment::CheckUpToDate(const std::wstring& source, const std::filesyste
231231
auto sourceInnerDirectory = std::filesystem::directory_entry(path);
232232
if (sourceInnerDirectory.path() != directoryToIgnore)
233233
{
234-
CheckUpToDate(destination / path.path().filename(), path.path(), extension, directoryToIgnore);
234+
CheckUpToDate(/* source */ path.path(), /* destination */ destination / path.path().filename(), extension, directoryToIgnore);
235235
}
236236
}
237237
}

src/Servers/IIS/IIS/test/IIS.ShadowCopy.Tests/ShadowCopyTests.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
using System.IO;
6-
using System.Threading.Tasks;
4+
using Microsoft.AspNetCore.InternalTesting;
75
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
86
using Microsoft.AspNetCore.Testing;
97
using Xunit;
@@ -142,6 +140,37 @@ public async Task ShadowCopySingleFileChangedWorks()
142140
Assert.True(response.IsSuccessStatusCode);
143141
}
144142

143+
[ConditionalFact]
144+
public async Task ShadowCopyDeleteFolderDuringShutdownWorks()
145+
{
146+
using var directory = TempDirectory.Create();
147+
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
148+
deploymentParameters.HandlerSettings["enableShadowCopy"] = "true";
149+
deploymentParameters.HandlerSettings["shadowCopyDirectory"] = directory.DirectoryPath;
150+
151+
var deploymentResult = await DeployAsync(deploymentParameters);
152+
var deleteDirPath = Path.Combine(deploymentResult.ContentRoot, "wwwroot/deletethis");
153+
Directory.CreateDirectory(deleteDirPath);
154+
File.WriteAllText(Path.Combine(deleteDirPath, "file.dll"), "");
155+
156+
var response = await deploymentResult.HttpClient.GetAsync("Wow!");
157+
Assert.True(response.IsSuccessStatusCode);
158+
159+
AddAppOffline(deploymentResult.ContentRoot);
160+
await AssertAppOffline(deploymentResult);
161+
162+
// Delete folder + file after app is shut down
163+
// Testing specific path on startup where we compare the app directory contents with the shadow copy directory
164+
Directory.Delete(deleteDirPath, recursive: true);
165+
166+
RemoveAppOffline(deploymentResult.ContentRoot);
167+
168+
await deploymentResult.AssertRecycledAsync();
169+
170+
response = await deploymentResult.HttpClient.GetAsync("Wow!");
171+
Assert.True(response.IsSuccessStatusCode);
172+
}
173+
145174
[ConditionalFact]
146175
public async Task ShadowCopyE2EWorksWithFolderPresent()
147176
{

0 commit comments

Comments
 (0)