commit 4073c4304e6a87db3cbf0826bb694d9296072cd3 parent 2979fd81dedd79f06bb0061159f6764b4ac70a9a Author: Kaleb Luedtke <trenlymc@gmail.com> Date: Tue, 7 May 2024 13:33:11 -0500 Remove Installer Parent Directory when Empty (#4451) Diffstat:
| M | src/AppInstallerCLICore/Workflows/DownloadFlow.cpp | | | 11 | +++++++++++ |
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp b/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp @@ -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) {