unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#33376] fixes related to 'guix publish' being run without the '--cache' option
@ 2018-11-14 10:10 Clément Lassieur
  2018-11-14 10:13 ` [bug#33376] [PATCH 1/2] progress: Fix crash because of division by zero Clément Lassieur
  0 siblings, 1 reply; 5+ messages in thread
From: Clément Lassieur @ 2018-11-14 10:10 UTC (permalink / raw)
  To: 33376

Hi,

These two patches fix some issues I have when using 'guix publish'
without the '--cache' option.

The first fixes a crash.

The second makes sure the last display is not a 0B display, which is
annoying because it's the only one that remains on the screen.

Cheers,
Clément

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#33376] [PATCH 1/2] progress: Fix crash because of division by zero.
  2018-11-14 10:10 [bug#33376] fixes related to 'guix publish' being run without the '--cache' option Clément Lassieur
@ 2018-11-14 10:13 ` Clément Lassieur
  2018-11-14 10:13   ` [bug#33376] [PATCH 2/2] progress: Do not display the last 0B transfer when size is unknown Clément Lassieur
  0 siblings, 1 reply; 5+ messages in thread
From: Clément Lassieur @ 2018-11-14 10:13 UTC (permalink / raw)
  To: 33376

* guix/progress.scm (display-download-progress): Handle the case where SIZE is
null.
---
 guix/progress.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/guix/progress.scm b/guix/progress.scm
index 9da667a02..7a25f11bd 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Sou Bunnbu <iyzsong@gmail.com>
 ;;; Copyright © 2015 Steve Sprang <scs@stevesprang.com>
 ;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -197,7 +198,7 @@ throughput."
   (define elapsed
     (duration->seconds
      (time-difference (current-time time-monotonic) start-time)))
-  (if (number? size)
+  (if (and (number? size) (not (zero? size)))
       (let* ((%  (* 100.0 (/ transferred size)))
              (throughput (/ transferred elapsed))
              (left       (format #f " ~a  ~a" file
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#33376] [PATCH 2/2] progress: Do not display the last 0B transfer when size is unknown.
  2018-11-14 10:13 ` [bug#33376] [PATCH 1/2] progress: Fix crash because of division by zero Clément Lassieur
@ 2018-11-14 10:13   ` Clément Lassieur
  2018-11-16 13:43     ` Mathieu Othacehe
  0 siblings, 1 reply; 5+ messages in thread
From: Clément Lassieur @ 2018-11-14 10:13 UTC (permalink / raw)
  To: 33376

* guix/progress.scm (display-download-progress): Don't display anything when
both SIZE and TRANSFERRED are null.
---
 guix/progress.scm | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/guix/progress.scm b/guix/progress.scm
index 7a25f11bd..65080bcf2 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -212,17 +212,20 @@ throughput."
                                     (current-terminal-columns))
                  log-port)
         (force-output log-port))
-      (let* ((throughput (/ transferred elapsed))
-             (left       (format #f " ~a" file))
-             (right      (format #f "~a/s ~a | ~a transferred"
-                                 (byte-count->string throughput)
-                                 (seconds->string elapsed)
-                                 (byte-count->string transferred))))
-        (erase-current-line log-port)
-        (display (string-pad-middle left right
-                                    (current-terminal-columns))
-                 log-port)
-        (force-output log-port))))
+      ;; If we don't know the total size, the last transfer will have a 0B
+      ;; size.  Don't display it.
+      (unless (zero? transferred)
+        (let* ((throughput (/ transferred elapsed))
+               (left       (format #f " ~a" file))
+               (right      (format #f "~a/s ~a | ~a transferred"
+                                   (byte-count->string throughput)
+                                   (seconds->string elapsed)
+                                   (byte-count->string transferred))))
+          (erase-current-line log-port)
+          (display (string-pad-middle left right
+                                      (current-terminal-columns))
+                   log-port)
+          (force-output log-port)))))
 
 (define %progress-interval
   ;; Default interval between subsequent outputs for rate-limited displays.
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#33376] [PATCH 2/2] progress: Do not display the last 0B transfer when size is unknown.
  2018-11-14 10:13   ` [bug#33376] [PATCH 2/2] progress: Do not display the last 0B transfer when size is unknown Clément Lassieur
@ 2018-11-16 13:43     ` Mathieu Othacehe
  2018-11-16 13:55       ` bug#33376: " Clément Lassieur
  0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Othacehe @ 2018-11-16 13:43 UTC (permalink / raw)
  To: Clément Lassieur; +Cc: 33376


Hi Clément,

This patch and the previous one LGTM.

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33376: [PATCH 2/2] progress: Do not display the last 0B transfer when size is unknown.
  2018-11-16 13:43     ` Mathieu Othacehe
@ 2018-11-16 13:55       ` Clément Lassieur
  0 siblings, 0 replies; 5+ messages in thread
From: Clément Lassieur @ 2018-11-16 13:55 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 33376-done

Mathieu Othacehe <m.othacehe@gmail.com> writes:

> Hi Clément,
>
> This patch and the previous one LGTM.

Pushed, thank you for reviewing!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-16 13:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-14 10:10 [bug#33376] fixes related to 'guix publish' being run without the '--cache' option Clément Lassieur
2018-11-14 10:13 ` [bug#33376] [PATCH 1/2] progress: Fix crash because of division by zero Clément Lassieur
2018-11-14 10:13   ` [bug#33376] [PATCH 2/2] progress: Do not display the last 0B transfer when size is unknown Clément Lassieur
2018-11-16 13:43     ` Mathieu Othacehe
2018-11-16 13:55       ` bug#33376: " Clément Lassieur

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).