]> git.ipfire.org Git - pakfire.git/commitdiff
transaction: Automatically solve if not done, yet
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Sep 2023 10:07:18 +0000 (10:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Sep 2023 10:07:18 +0000 (10:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/transaction.c

index 1a169ef0a3a22c3842b79fd1e402e9aba334b166..3c7ea113cd3f7fdcc5a43724aee9d0b2d9aa7ea3 100644 (file)
@@ -54,9 +54,6 @@ struct pakfire_transaction {
 
        // The solver
        Solver* solver;
-       enum pakfire_transaction_solver_status {
-               SOLVER_STATUS_UNKNOWN,
-       } solver_status;
 
        // The jobs to solve
        Queue jobs;
@@ -1968,10 +1965,15 @@ ERROR:
 
 PAKFIRE_EXPORT int pakfire_transaction_run(
                struct pakfire_transaction* transaction, int flags) {
+       char* dump = NULL;
        int r;
 
-       // XXX automatically solve
-       // XXX automatically download
+       // Automatically solve if not done, yet
+       if (!transaction->transaction) {
+               r = pakfire_transaction_solve(transaction, 0, NULL);
+               if (r)
+                       goto ERROR;
+       }
 
        // Skip running an empty transaction
        if (!transaction->num) {
@@ -1980,7 +1982,7 @@ PAKFIRE_EXPORT int pakfire_transaction_run(
        }
 
        // Show what would be done
-       char* dump = pakfire_transaction_dump(transaction, 80);
+       dump = pakfire_transaction_dump(transaction, 80);
 
        // Check if we should continue
        r = pakfire_confirm(transaction->pakfire, dump, _("Is this okay?"));
@@ -2010,7 +2012,8 @@ PAKFIRE_EXPORT int pakfire_transaction_run(
 
 ERROR:
        // Cleanup
-       free(dump);
+       if (dump)
+               free(dump);
 
        return r;
 }