Skip to content

Commit

Permalink
Don't recursive copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotalik committed Mar 19, 2021
1 parent 254ab40 commit dca5ec4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHt
}

shadowCopyPath = shadowCopyPath / directoryNameStr;
HRESULT hr = Environment::CopyToDirectory(physicalPath, shadowCopyPath, options.QueryCleanShadowCopyDirectory(), shadowCopyBaseDirectory.path().parent_path());
HRESULT hr = Environment::CopyToDirectory(physicalPath, shadowCopyPath, options.QueryCleanShadowCopyDirectory(), std::filesystem::canonical(shadowCopyBaseDirectory.path()));
if (hr != S_OK)
{
return std::wstring();
Expand Down
6 changes: 4 additions & 2 deletions src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ void Environment::CopyToDirectoryInner(const std::filesystem::path& source, cons
}
else if (path.is_directory())
{
auto sourceInnerDirectory = std::filesystem::directory_entry(path);
if (sourceInnerDirectory.path() != directoryToIgnore)
auto sourceInnerDirectory = path.path();

// Make sure we aren't navigating into shadow copy directory.
if (sourceInnerDirectory.wstring().rfind(directoryToIgnore, 0) != 0)
{
CopyToDirectoryInner(path.path(), destination / path.path().filename(), directoryToIgnore);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ DWORD WINAPI FILE_WATCHER::CopyAndShutdown(FILE_WATCHER* watcher)
// Copy contents before shutdown
try
{
Environment::CopyToDirectory(watcher->_strDirectoryName.QueryStr(), destination, false, parentDirectory);
Environment::CopyToDirectory(watcher->_strDirectoryName.QueryStr(), destination, false, std::filesystem::canonical(parentDirectory));
}
catch (...)
{
Expand Down

0 comments on commit dca5ec4

Please sign in to comment.