commit 0653f2c506b47d61930b781c550d6ae6adb4237b
parent 2f4c511a3947636efef7d821f48eb06b57eb9327
Author: JohnMcPMS <johnmcp@microsoft.com>
Date: Thu, 7 May 2020 21:48:06 -0700
gs (#111)
Nothing is currently cleaning up installers from the temp location. This change causes successful installs to remove the installer file, which should reduce the amount of data we leave around significantly. When we support local installers, we will need to ensure that we don't attempt to delete them here, but for now since anything that we download is temporary, this should be ok.
Diffstat:
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/AppInstallerCLICore/Commands/InstallCommand.cpp b/src/AppInstallerCLICore/Commands/InstallCommand.cpp
@@ -56,7 +56,8 @@ namespace AppInstaller::CLI
Workflow::ShowInstallationDisclaimer <<
Workflow::DownloadInstaller <<
Workflow::VerifyInstallerHash <<
- Workflow::ExecuteInstaller;
+ Workflow::ExecuteInstaller <<
+ Workflow::RemoveInstaller;
}
void InstallCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
diff --git a/src/AppInstallerCLICore/Workflows/InstallFlow.cpp b/src/AppInstallerCLICore/Workflows/InstallFlow.cpp
@@ -223,4 +223,15 @@ namespace AppInstaller::CLI::Workflow
context.Reporter.Info() << "Successfully installed." << std::endl;
}
+
+ void RemoveInstaller(Execution::Context& context)
+ {
+ // Path may not be present if installed from a URL for MSIX
+ if (context.Contains(Execution::Data::InstallerPath))
+ {
+ const auto& path = context.Get<Execution::Data::InstallerPath>();
+ AICLI_LOG(CLI, Info, << "Removing installer: " << path);
+ std::filesystem::remove(path);
+ }
+ }
}
diff --git a/src/AppInstallerCLICore/Workflows/InstallFlow.h b/src/AppInstallerCLICore/Workflows/InstallFlow.h
@@ -70,4 +70,10 @@ namespace AppInstaller::CLI::Workflow
// Inputs: Manifest?, Installer || InstallerPath
// Outputs: None
void MsixInstall(Execution::Context& context);
+
+ // Deletes the installer file.
+ // Required Args: None
+ // Inputs: InstallerPath
+ // Outputs: None
+ void RemoveInstaller(Execution::Context& context);
}
diff --git a/src/AppInstallerCLITests/WorkFlow.cpp b/src/AppInstallerCLITests/WorkFlow.cpp
@@ -116,7 +116,19 @@ struct WorkflowTaskOverride
// Enables overriding the behavior of specific workflow tasks.
struct TestContext : public Context
{
- TestContext(std::ostream& out, std::istream& in) : Context(out, in) {}
+ TestContext(std::ostream& out, std::istream& in) : Context(out, in)
+ {
+ WorkflowTaskOverride wto
+ { RemoveInstaller, [](TestContext&)
+ {
+ // Do nothing; we never want to remove the test files.
+ } };
+
+ // Mark this one as used so that it doesn't anger the destructor.
+ wto.Used = true;
+
+ Override(wto);
+ }
~TestContext()
{