Skip to content

Fix shadow copy up to date check on startup #52831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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()
{
Expand Down