Skip to content

Commit

Permalink
[DNF5] Fix: Remove transaction_store_path from public, add getter/setter
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel committed Apr 23, 2024
1 parent 62ef871 commit 73a4416
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
15 changes: 13 additions & 2 deletions dnf5/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }

Expand All @@ -185,6 +186,8 @@ class Context::Impl {
private:
Context & owner;

std::filesystem::path transaction_store_path;

libdnf5::Base base;
std::vector<std::pair<std::string, std::string>> setopts;
std::vector<std::pair<std::string, std::string>> repos_from_path;
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions dnf5/include/dnf5/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions dnf5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion dnf5/shared_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down

0 comments on commit 73a4416

Please sign in to comment.