[pacman-dev] [PATCH] Adds a "retry?" prompt for when transaction creation fails for user-friendlier fail support.

Pedro pedrocga1 at gmail.com
Mon Apr 27 22:02:35 UTC 2020


Signed-off-by: Pedro <pedrocga1 at gmail.com>
---
 src/pacman/remove.c  | 13 ++++++++++---
 src/pacman/sync.c    | 13 ++++++++++---
 src/pacman/upgrade.c | 13 ++++++++++---
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 9920f502..f61c8652 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -87,9 +87,16 @@ int pacman_remove(alpm_list_t *targets)
 	}
 
 	/* Step 0: create a new transaction */
-	if(trans_init(config->flags, 0) == -1) {
-		return 1;
-	}
+    while(1) {
+        if(trans_init(config->flags, 1) == -1) {
+            if(yesno(_("Retry?")) == 0) {
+				return 1;
+            }
+            /* Try again */
+            continue;
+        }
+        break;
+    }
 
 	/* Step 1: add targets to the created transaction */
 	for(i = targets; i; i = alpm_list_next(i)) {
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index f7dcb958..89f01061 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -694,9 +694,16 @@ static int sync_trans(alpm_list_t *targets)
 	alpm_list_t *i;
 
 	/* Step 1: create a new transaction... */
-	if(trans_init(config->flags, 1) == -1) {
-		return 1;
-	}
+    while(1) {
+        if(trans_init(config->flags, 1) == -1) {
+            if(yesno(_("Retry?")) == 0) {
+				return 1;
+            }
+            /* Try again */
+            continue;
+        }
+        break;
+    }
 
 	/* process targets */
 	for(i = targets; i; i = alpm_list_next(i)) {
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 5f984e44..406fec24 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -79,9 +79,16 @@ int pacman_upgrade(alpm_list_t *targets)
 	}
 
 	/* Step 1: create a new transaction */
-	if(trans_init(config->flags, 1) == -1) {
-		retval = 1;
-		goto fail_free;
+	while(1) {
+		if(trans_init(config->flags, 1) == -1) {
+			if(yesno(_("Retry?")) == 0) {
+				retval = 1;
+				goto fail_free;
+			}
+			/* Try again */
+			continue;
+		}
+		break;
 	}
 
 	printf(_("loading packages...\n"));
-- 
2.26.2


More information about the pacman-dev mailing list