diff --git a/dnf5/context.cpp b/dnf5/context.cpp index 9c14e2c06..5c9c4c6b4 100644 --- a/dnf5/context.cpp +++ b/dnf5/context.cpp @@ -117,8 +117,6 @@ class Context::Impl { void store_offline(libdnf5::base::Transaction & transaction); - std::filesystem::path transaction_store_path; - const char * get_comment() const noexcept { return comment; } void set_comment(const char * comment) noexcept { this->comment = comment; } @@ -171,6 +169,9 @@ class Context::Impl { void set_output_stream(std::ostream & new_output_stream) { output_stream = new_output_stream; } + void set_transaction_store_path(std::filesystem::path path) { transaction_store_path = path; } + const std::filesystem::path & get_transaction_store_path() const { return transaction_store_path; } + void set_should_store_offline(bool should_store_offline) { this->should_store_offline = should_store_offline; } bool get_should_store_offline() const { return should_store_offline; } @@ -185,6 +186,8 @@ class Context::Impl { private: Context & owner; + std::filesystem::path transaction_store_path; + libdnf5::Base base; std::vector> setopts; std::vector> repos_from_path; @@ -590,6 +593,14 @@ void Context::set_output_stream(std::ostream & new_output_stream) { p_impl->set_output_stream(new_output_stream); } +void Context::set_transaction_store_path(std::filesystem::path path) { + p_impl->set_transaction_store_path(path); +} + +const std::filesystem::path & Context::get_transaction_store_path() const { + return p_impl->get_transaction_store_path(); +} + void Context::set_should_store_offline(bool should_store_offline) { p_impl->set_should_store_offline(should_store_offline); } diff --git a/dnf5/include/dnf5/context.hpp b/dnf5/include/dnf5/context.hpp index 87a6a9456..b0074c326 100644 --- a/dnf5/include/dnf5/context.hpp +++ b/dnf5/include/dnf5/context.hpp @@ -83,10 +83,6 @@ class Context : public libdnf5::cli::session::Session { void store_offline(libdnf5::base::Transaction & transaction); - // When set current transaction is not executed but rather stored to - // the specified path. - std::filesystem::path transaction_store_path; - /// Gets user comment. const char * get_comment() const noexcept; @@ -147,6 +143,10 @@ class Context : public libdnf5::cli::session::Session { void set_output_stream(std::ostream & new_output_stream); + // When set current transaction is not executed but rather stored to the specified path. + void set_transaction_store_path(std::filesystem::path path); + const std::filesystem::path & get_transaction_store_path() const; + // Store the transaction to be run later in a minimal boot environment, // using `dnf5 offline` void set_should_store_offline(bool should_store_offline); diff --git a/dnf5/main.cpp b/dnf5/main.cpp index 706a04d74..0ea36c427 100644 --- a/dnf5/main.cpp +++ b/dnf5/main.cpp @@ -1253,9 +1253,10 @@ int main(int argc, char * argv[]) try { dnf5::print_transaction_size_stats(context); - if (!context.transaction_store_path.empty()) { - std::cout << "The operation will only store the transaction in " << context.transaction_store_path - << "." << std::endl; + if (auto transaction_store_path = context.get_transaction_store_path(); + !transaction_store_path.empty()) { + std::cout << "The operation will only store the transaction in " << transaction_store_path << "." + << std::endl; } else if (base.get_config().get_downloadonly_option().get_value()) { std::cout << "The operation will only download packages for the transaction." << std::endl; } else { diff --git a/dnf5/shared_options.cpp b/dnf5/shared_options.cpp index feef5ddf8..c177fd008 100644 --- a/dnf5/shared_options.cpp +++ b/dnf5/shared_options.cpp @@ -139,7 +139,7 @@ void create_store_option(dnf5::Command & command) { [[maybe_unused]] libdnf5::cli::ArgumentParser::NamedArg * arg, [[maybe_unused]] const char * option, const char * value) { - ctx.transaction_store_path = value; + ctx.set_transaction_store_path(value); return true; }); }