mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
status: Guard against a numerical overflow condition.
Fixes <https://issues.guix.gnu.org/62766>. * guix/status.scm (update-build): Use 0 as progress when an exception occurs while computing it.
This commit is contained in:
parent
0f59fbe2db
commit
7747da6aed
1 changed files with 12 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2017-2023 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -190,9 +191,17 @@ (define (update %)
|
|||
((regexp-exec %fraction-line-rx line)
|
||||
=>
|
||||
(lambda (match)
|
||||
(let ((done (string->number (match:substring match 1)))
|
||||
(total (string->number (match:substring match 3))))
|
||||
(update (* 100. (/ done total))))))
|
||||
(let* ((done (string->number (match:substring match 1)))
|
||||
(total (string->number (match:substring match 3)))
|
||||
;; It's possible that both done and total are 0 (see:
|
||||
;; https://issues.guix.gnu.org/62766). Special case this
|
||||
;; pathological case as a null progress (0).
|
||||
(progress (catch 'numerical-overflow
|
||||
(lambda ()
|
||||
(/ done total))
|
||||
(lambda _
|
||||
0))))
|
||||
(update (* 100. progress)))))
|
||||
((regexp-exec %phase-start-rx line)
|
||||
=>
|
||||
(lambda (match)
|
||||
|
|
Loading…
Reference in a new issue