Skip to content

Commit

Permalink
Remove Parent Directory when Empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed May 7, 2024
1 parent 2979fd8 commit 8eab396
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/AppInstallerCLICore/Workflows/DownloadFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ namespace AppInstaller::CLI::Workflow
try
{
std::filesystem::remove(path);

// It is assumed that the parent of the installer path will always be a directory
// If it isn't, then something went severely wrong. However, we will check that
// it is a directory here just to be safe. If it is an empty directory, remove it

if (std::filesystem::is_directory(path.parent_path()) &&
std::filesystem::is_empty(path.parent_path())
)
{
std::filesystem::remove(path.parent_path());
}
}
catch (const std::exception& e)
{
Expand Down

0 comments on commit 8eab396

Please sign in to comment.