Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daemon: Reset the goal #1678

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dnf5daemon-server/dbus/interfaces/org.rpm.dnf.v0.Goal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
<arg name="error_msg" type="s" direction="out" />
</method>

<!--
reset:
Reset the prepared rpm transaction. After this call the session is ready to perform another rpm transaction.
-->
<method name="reset">
</method>

</interface>

</node>
10 changes: 10 additions & 0 deletions dnf5daemon-server/services/goal/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ void Goal::dbus_register() {
[this](sdbus::MethodCall call) -> void {
session.get_threads_manager().handle_method(*this, &Goal::cancel, call, session.session_locale);
});
dbus_object->registerMethod(
dnfdaemon::INTERFACE_GOAL, "reset", "", {}, "", {}, [this](sdbus::MethodCall call) -> void {
session.get_threads_manager().handle_method(*this, &Goal::reset, call, session.session_locale);
});
}

sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) {
Expand Down Expand Up @@ -346,3 +350,9 @@ sdbus::MethodReply Goal::cancel(sdbus::MethodCall & call) {
reply << error_msg;
return reply;
}

sdbus::MethodReply Goal::reset(sdbus::MethodCall & call) {
session.reset_goal();
auto reply = call.createReply();
return reply;
}
1 change: 1 addition & 0 deletions dnf5daemon-server/services/goal/goal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Goal : public IDbusSessionService {
sdbus::MethodReply get_transaction_problems(sdbus::MethodCall & call);
sdbus::MethodReply do_transaction(sdbus::MethodCall & call);
sdbus::MethodReply cancel(sdbus::MethodCall & call);
sdbus::MethodReply reset(sdbus::MethodCall & call);
};

#endif
5 changes: 5 additions & 0 deletions dnf5daemon-server/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,8 @@ void Session::store_transaction_offline() {

state.write();
}

void Session::reset_goal() {
transaction.reset(nullptr);
goal.reset();
}
2 changes: 2 additions & 0 deletions dnf5daemon-server/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class Session {
/// Setter for download cancel request flag.
void set_cancel_download(CancelDownload value) { cancel_download.store(value); }

void reset_goal();

private:
sdbus::IConnection & connection;
std::unique_ptr<libdnf5::Base> base;
Expand Down
5 changes: 5 additions & 0 deletions libdnf5/base/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3296,12 +3296,17 @@ void Goal::add_redo_transaction(
void Goal::reset() {
p_impl->module_specs.clear();
p_impl->rpm_specs.clear();
p_impl->rpm_reason_change_specs.clear();
p_impl->rpm_ids.clear();
p_impl->group_specs.clear();
p_impl->rpm_filepaths.clear();
p_impl->resolved_group_specs.clear();
p_impl->resolved_environment_specs.clear();
p_impl->group_specs.clear();
p_impl->rpm_goal = rpm::solv::GoalPrivate(p_impl->base);
p_impl->serialized_transaction.reset();
p_impl->revert_transactions.reset();
p_impl->redo_transaction.reset();
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved
}

BaseWeakPtr Goal::get_base() const {
Expand Down
Loading