From: Arvin Schnell Date: Tue, 28 Nov 2023 07:35:35 +0000 (+0100) Subject: - report plugin failures X-Git-Tag: v0.10.7~3^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23d7a13b4cef56b7a02ad06b437e7702935764e2;p=thirdparty%2Fsnapper.git - report plugin failures --- diff --git a/client/cleanup.cc b/client/cleanup.cc index e57a0a80..626a0b65 100644 --- a/client/cleanup.cc +++ b/client/cleanup.cc @@ -110,8 +110,8 @@ public: virtual ~Cleaner() {} - void cleanup(); - void cleanup(std::function condition); + void cleanup(Plugins::Report& report); + void cleanup(std::function condition, Plugins::Report& report); protected: @@ -139,7 +139,7 @@ protected: // snapshot but which is not included in tmp. void filter_pre_post(ProxySnapshots& snapshots, list& tmp) const; - void remove(const list& tmp); + void remove(const list& tmp, Plugins::Report& report); // Should the cleanup with quota space be run? bool is_quota_aware() const; @@ -153,8 +153,8 @@ protected: // Is the free space condition satisfied? bool is_free_satisfied() const; - void cleanup(ProxySnapshots& snapshots); - void cleanup(ProxySnapshots& snapshots, std::function condition); + void cleanup(ProxySnapshots& snapshots, Plugins::Report& report); + void cleanup(ProxySnapshots& snapshots, std::function condition, Plugins::Report& report); ProxySnapper* snapper; @@ -240,11 +240,11 @@ Cleaner::filter_pre_post(ProxySnapshots& snapshots, list& tmp) +Cleaner::remove(const list& tmp, Plugins::Report& report) { for (list::const_iterator it = tmp.begin(); it != tmp.end(); ++it) { - snapper->deleteSnapshots({ *it }, verbose); + snapper->deleteSnapshots({ *it }, verbose, report); } } @@ -334,18 +334,18 @@ Cleaner::is_free_satisfied() const void -Cleaner::cleanup(ProxySnapshots& snapshots) +Cleaner::cleanup(ProxySnapshots& snapshots, Plugins::Report& report) { list candidates = calculate_candidates(snapshots, Range::MAX); filter(snapshots, candidates); - remove(candidates); + remove(candidates, report); } void -Cleaner::cleanup(ProxySnapshots& snapshots, std::function condition) +Cleaner::cleanup(ProxySnapshots& snapshots, std::function condition, Plugins::Report& report) { while (!condition()) { @@ -374,7 +374,7 @@ Cleaner::cleanup(ProxySnapshots& snapshots, std::function condition) if (!tmp.empty()) { - remove(tmp); + remove(tmp, report); // after removing snapshots the condition must be reevaluated break; @@ -400,7 +400,7 @@ Cleaner::cleanup(ProxySnapshots& snapshots, std::function condition) void -Cleaner::cleanup() +Cleaner::cleanup(Plugins::Report& report) { ProxySnapshots& snapshots = snapper->getSnapshots(); @@ -408,7 +408,7 @@ Cleaner::cleanup() cout << "cleanup without condition" << '\n'; #endif - cleanup(snapshots); + cleanup(snapshots, report); if (is_quota_aware()) { @@ -416,7 +416,7 @@ Cleaner::cleanup() cout << "cleanup with quota condition" << '\n'; #endif - cleanup(snapshots, std::bind(&Cleaner::is_quota_satisfied, this)); + cleanup(snapshots, std::bind(&Cleaner::is_quota_satisfied, this), report); } else { @@ -431,7 +431,7 @@ Cleaner::cleanup() cout << "cleanup with free condition" << '\n'; #endif - cleanup(snapshots, std::bind(&Cleaner::is_free_satisfied, this)); + cleanup(snapshots, std::bind(&Cleaner::is_free_satisfied, this), report); } else { @@ -443,7 +443,7 @@ Cleaner::cleanup() void -Cleaner::cleanup(std::function condition) +Cleaner::cleanup(std::function condition, Plugins::Report& report) { ProxySnapshots& snapshots = snapper->getSnapshots(); @@ -451,7 +451,7 @@ Cleaner::cleanup(std::function condition) cout << "cleanup with user condition" << '\n'; #endif - cleanup(snapshots, condition); + cleanup(snapshots, condition, report); } @@ -562,20 +562,20 @@ private: void -do_cleanup_number(ProxySnapper* snapper, bool verbose) +do_cleanup_number(ProxySnapper* snapper, bool verbose, Plugins::Report& report) { NumberParameters parameters(snapper); NumberCleaner cleaner(snapper, verbose, parameters); - cleaner.cleanup(); + cleaner.cleanup(report); } void -do_cleanup_number(ProxySnapper* snapper, bool verbose, std::function condition) +do_cleanup_number(ProxySnapper* snapper, bool verbose, std::function condition, Plugins::Report& report) { NumberParameters parameters(snapper); NumberCleaner cleaner(snapper, verbose, parameters); - cleaner.cleanup(condition); + cleaner.cleanup(condition, report); } @@ -778,20 +778,20 @@ private: void -do_cleanup_timeline(ProxySnapper* snapper, bool verbose) +do_cleanup_timeline(ProxySnapper* snapper, bool verbose, Plugins::Report& report) { TimelineParameters parameters(snapper); TimelineCleaner cleaner(snapper, verbose, parameters); - cleaner.cleanup(); + cleaner.cleanup(report); } void -do_cleanup_timeline(ProxySnapper* snapper, bool verbose, std::function condition) +do_cleanup_timeline(ProxySnapper* snapper, bool verbose, std::function condition, Plugins::Report& report) { TimelineParameters parameters(snapper); TimelineCleaner cleaner(snapper, verbose, parameters); - cleaner.cleanup(condition); + cleaner.cleanup(condition, report); } @@ -852,18 +852,19 @@ private: void -do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose) +do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose, Plugins::Report& report) { EmptyPrePostParameters parameters(snapper); EmptyPrePostCleaner cleaner(snapper, verbose, parameters); - cleaner.cleanup(); + cleaner.cleanup(report); } void -do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose, std::function condition) +do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose, std::function condition, + Plugins::Report& report) { EmptyPrePostParameters parameters(snapper); EmptyPrePostCleaner cleaner(snapper, verbose, parameters); - cleaner.cleanup(condition); + cleaner.cleanup(condition, report); } diff --git a/client/cleanup.h b/client/cleanup.h index 6d250079..aceaab80 100644 --- a/client/cleanup.h +++ b/client/cleanup.h @@ -32,13 +32,13 @@ */ void -do_cleanup_number(ProxySnapper* snapper, bool verbose); +do_cleanup_number(ProxySnapper* snapper, bool verbose, Plugins::Report& report); void -do_cleanup_timeline(ProxySnapper* snapper, bool verbose); +do_cleanup_timeline(ProxySnapper* snapper, bool verbose, Plugins::Report& report); void -do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose); +do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose, Plugins::Report& report); /* @@ -47,10 +47,13 @@ do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose); */ void -do_cleanup_number(ProxySnapper* snapper, bool verbose, std::function condition); +do_cleanup_number(ProxySnapper* snapper, bool verbose, std::function condition, + Plugins::Report& report); void -do_cleanup_timeline(ProxySnapper* snapper, bool verbose, std::function condition); +do_cleanup_timeline(ProxySnapper* snapper, bool verbose, std::function condition, + Plugins::Report& report); void -do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose, std::function condition); +do_cleanup_empty_pre_post(ProxySnapper* snapper, bool verbose, std::function condition, + Plugins::Report& report); diff --git a/client/cmd-cleanup.cc b/client/cmd-cleanup.cc index 3fd90e37..42e28b12 100644 --- a/client/cmd-cleanup.cc +++ b/client/cmd-cleanup.cc @@ -109,26 +109,26 @@ namespace snapper void - run_cleanup(ProxySnapper* snapper, CleanupAlgorithm cleanup_algorithm, bool verbose) + run_cleanup(ProxySnapper* snapper, CleanupAlgorithm cleanup_algorithm, bool verbose, Plugins::Report& report) { switch (cleanup_algorithm) { case CleanupAlgorithm::NUMBER: - do_cleanup_number(snapper, verbose); + do_cleanup_number(snapper, verbose, report); break; case CleanupAlgorithm::TIMELINE: - do_cleanup_timeline(snapper, verbose); + do_cleanup_timeline(snapper, verbose, report); break; case CleanupAlgorithm::EMPTY_PRE_POST: - do_cleanup_empty_pre_post(snapper, verbose); + do_cleanup_empty_pre_post(snapper, verbose, report); break; case CleanupAlgorithm::ALL: - do_cleanup_number(snapper, verbose); - do_cleanup_timeline(snapper, verbose); - do_cleanup_empty_pre_post(snapper, verbose); + do_cleanup_number(snapper, verbose, report); + do_cleanup_timeline(snapper, verbose, report); + do_cleanup_empty_pre_post(snapper, verbose, report); break; } } @@ -136,7 +136,7 @@ namespace snapper void run_cleanup(ProxySnapper* snapper, CleanupAlgorithm cleanup_algorithm, bool verbose, - const FreeSpaceCondition& free_space_condition) + const FreeSpaceCondition& free_space_condition, Plugins::Report& report) { std::function condition = [snapper, &free_space_condition]() { return free_space_condition.is_satisfied(snapper); @@ -145,28 +145,29 @@ namespace snapper switch (cleanup_algorithm) { case CleanupAlgorithm::NUMBER: - do_cleanup_number(snapper, verbose, condition); + do_cleanup_number(snapper, verbose, condition, report); break; case CleanupAlgorithm::TIMELINE: - do_cleanup_timeline(snapper, verbose, condition); + do_cleanup_timeline(snapper, verbose, condition, report); break; case CleanupAlgorithm::EMPTY_PRE_POST: - do_cleanup_empty_pre_post(snapper, verbose, condition); + do_cleanup_empty_pre_post(snapper, verbose, condition, report); break; case CleanupAlgorithm::ALL: - do_cleanup_number(snapper, verbose, condition); - do_cleanup_timeline(snapper, verbose, condition); - do_cleanup_empty_pre_post(snapper, verbose, condition); + do_cleanup_number(snapper, verbose, condition, report); + do_cleanup_timeline(snapper, verbose, condition, report); + do_cleanup_empty_pre_post(snapper, verbose, condition, report); break; } } void - run_cleanup(const vector& snappers, CleanupAlgorithm cleanup_algorithm, bool verbose) + run_cleanup(const vector& snappers, CleanupAlgorithm cleanup_algorithm, bool verbose, + Plugins::Report& report) { for (ProxySnapper* snapper : snappers) { @@ -174,14 +175,14 @@ namespace snapper cout << "config " << snapper->configName() << '\n'; #endif - run_cleanup(snapper, cleanup_algorithm, verbose); + run_cleanup(snapper, cleanup_algorithm, verbose, report); } } void run_cleanup(const vector& snappers, CleanupAlgorithm cleanup_algorithm, bool verbose, - const FreeSpaceCondition& free_space_condition) + const FreeSpaceCondition& free_space_condition, Plugins::Report& report) { for (ProxySnapper* snapper : snappers) { @@ -194,7 +195,7 @@ namespace snapper try { - run_cleanup(snapper, cleanup_algorithm, verbose, free_space_condition); + run_cleanup(snapper, cleanup_algorithm, verbose, free_space_condition, report); } catch (...) { @@ -209,7 +210,8 @@ namespace snapper void - command_cleanup(GlobalOptions& global_options, GetOpts& get_opts, ProxySnappers* snappers, ProxySnapper*) + command_cleanup(GlobalOptions& global_options, GetOpts& get_opts, ProxySnappers* snappers, + ProxySnapper*, Plugins::Report& report) { const vector