From 20d105a65d305c724948ce389654c74cacac013c Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 8 Mar 2024 10:21:46 +0100 Subject: gc: add option --no-rotation ... to clean up what can be done without losing cache information. --- src/buildtool/common/cli.hpp | 12 ++++++++++++ src/buildtool/main/cli.cpp | 1 + src/buildtool/main/cli.hpp | 1 + src/buildtool/main/main.cpp | 3 ++- 4 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index 387092bc..5b8df960 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -180,6 +180,10 @@ struct ServeArguments { std::vector repositories{}; }; +struct GcArguments { + bool no_rotate{}; +}; + static inline auto SetupCommonArguments( gsl::not_null const& app, gsl::not_null const& clargs) { @@ -723,4 +727,12 @@ static inline void SetupRetryArguments( "the resources that survived the outage. (Default: 60)"); } +static inline void SetupGcArguments(gsl::not_null const& app, + gsl::not_null const& args) { + app->add_flag("--no-rotate", + args->no_rotate, + "Do not rotate cache generations, only clean up what can be " + "done without losing cache."); +} + #endif // INCLUDED_SRC_BUILDTOOL_COMMON_CLI_HPP diff --git a/src/buildtool/main/cli.cpp b/src/buildtool/main/cli.cpp index c5da32bb..413befa6 100644 --- a/src/buildtool/main/cli.cpp +++ b/src/buildtool/main/cli.cpp @@ -127,6 +127,7 @@ auto SetupGcCommandArguments( gsl::not_null const& clargs) { SetupLogArguments(app, &clargs->log); SetupCacheArguments(app, &clargs->endpoint); + SetupGcArguments(app, &clargs->gc); } /// \brief Setup arguments for sub command "just execute". diff --git a/src/buildtool/main/cli.hpp b/src/buildtool/main/cli.hpp index 1ca45255..04ae2a16 100644 --- a/src/buildtool/main/cli.hpp +++ b/src/buildtool/main/cli.hpp @@ -52,6 +52,7 @@ struct CommandLineArguments { ServiceArguments service; ServeArguments serve; RetryArguments retry; + GcArguments gc; }; auto ParseCommandLineArguments(int argc, char const* const* argv) diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 5241fa54..78ec57a7 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -857,7 +857,8 @@ auto main(int argc, char* argv[]) -> int { SetupAuthConfig(arguments.auth, arguments.cauth, arguments.sauth); if (arguments.cmd == SubCommand::kGc) { - if (GarbageCollector::TriggerGarbageCollection()) { + if (GarbageCollector::TriggerGarbageCollection( + arguments.gc.no_rotate)) { return kExitSuccess; } return kExitFailure; -- cgit v1.2.3