Skip to content

Fix shadow copy up to date check on startup (#52831) #55659

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

Closed
wants to merge 2 commits into from
Closed
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)
Copy link
Member

@halter73 halter73 May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is unchanged, but why is this logic different than CopyToDirectoryInner? It feels like we should use the same logic in both places if possible. We could do that in main though.

            auto sourceInnerDirectory = path.path();

            if (sourceInnerDirectory.wstring().rfind(directoryToIgnore, 0) != 0)

And what is auto sourceInnerDirectory = std::filesystem::directory_entry(path); doing? Isn't path already a directory_entry?

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