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

Message ID 20200427220235.2248-1-pedrocga1@gmail.com
State Rejected, archived
Headers show
Series [pacman-dev] Adds a "retry?" prompt for when transaction creation fails for user-friendlier fail support. | expand

Commit Message

Pedro April 27, 2020, 10:02 p.m. UTC
Signed-off-by: Pedro <pedrocga1@gmail.com>
---
 src/pacman/remove.c  | 13 ++++++++++---
 src/pacman/sync.c    | 13 ++++++++++---
 src/pacman/upgrade.c | 13 ++++++++++---
 3 files changed, 30 insertions(+), 9 deletions(-)

Comments

Eli Schwartz April 27, 2020, 10:11 p.m. UTC | #1
What do you propose the user do about this if a transaction fails to be
created? What should the user think if they see the message "Retry?" here?
Pedro April 27, 2020, 10:23 p.m. UTC | #2
You're right, I'll write specific messages for each operation. Thanks for
the feedback.

On Mon, Apr 27, 2020, 19:11 Eli Schwartz <eschwartz@archlinux.org> wrote:

> What do you propose the user do about this if a transaction fails to be
> created? What should the user think if they see the message "Retry?" here?
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>
>

Patch

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"));