aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2020-09-14 23:46:48 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2020-10-08 11:10:18 -0400
commit7102c18678dc02d5ee6c77a9a70ae344482af841 (patch)
treeab73f7b97f6e43244e279fb94320643cdcc3155e
parentcde87f38cf535d717fd46b19b988404d52f02c59 (diff)
downloadguix-7102c18678dc02d5ee6c77a9a70ae344482af841.tar.gz
guix-7102c18678dc02d5ee6c77a9a70ae344482af841.zip
utils: Do not raise exceptions in delete-file-recursively.
This makes it so that delete-file-recursively honors its docstring, which says it should "report but ignore errors". Fixes <https://issues.guix.gnu.org/43366>. * guix/build/utils.scm (warn-on-error): New syntax. (delete-file-recursively): Use it to catch exceptions and print warning messages. Reported-by: Fredrik Salomonsson <plattfot@gmail.com>
-rw-r--r--guix/build/utils.scm15
1 files changed, 13 insertions, 2 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index afcb71fae3..533b740896 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -383,6 +384,16 @@ verbose output to the LOG port."
stat
lstat)))
+(define-syntax-rule (warn-on-error expr file)
+ (catch 'system-error
+ (lambda ()
+ expr)
+ (lambda args
+ (format (current-error-port)
+ "warning: failed to delete ~a: ~a~%"
+ file (strerror
+ (system-error-errno args))))))
+
(define* (delete-file-recursively dir
#:key follow-mounts?)
"Delete DIR recursively, like `rm -rf', without following symlinks. Don't
@@ -393,10 +404,10 @@ errors."
(or follow-mounts?
(= dev (stat:dev stat))))
(lambda (file stat result) ; leaf
- (delete-file file))
+ (warn-on-error (delete-file file) file))
(const #t) ; down
(lambda (dir stat result) ; up
- (rmdir dir))
+ (warn-on-error (rmdir dir) dir))
(const #t) ; skip
(lambda (file stat errno result)
(format (current-error-port)
urce from Savannah again.Maxim Cournoyer 2022-06-01gnu: Add h-client (again, this time with Python 3 support).Maxim Cournoyer 2022-05-29gnu: hwinfo: Rename non-standard ‘dev’ output.Tobias Geerinckx-Rice 2022-05-29gnu: hwinfo: Update to 21.81.Tobias Geerinckx-Rice 2022-05-29gnu: ddcui: Update to 0.2.1.Tobias Geerinckx-Rice 2022-05-29gnu: ddcutil: Update to 1.2.2.Tobias Geerinckx-Rice 2022-05-31gnu: Remove h-client.Maxim Cournoyer 2022-04-29gnu: Add envytools.Petr Hodina 2022-03-18gnu: Add ckb-next.Formbi 2022-02-07gnu: ddcutil: Update to 1.2.1.Efraim Flashner 2022-02-03gnu: usbguard: Remove input labels.Marius Bakke 2022-02-03gnu: usbguard: Update to 1.0.0-55-g466f1f0.Marius Bakke 2022-01-21gnu: Add libcpuid.Zhu Zihao 2022-01-06gnu: Add openrgb.John Kehayias 2022-01-06gnu: Add hueplusplus.John Kehayias 2021-12-29gnu: hwinfo: Update to 21.80.Tobias Geerinckx-Rice 2021-12-27gnu: Add headsetcontrol.John Kehayias 2021-12-14gnu: i7z: Fix building with GCC >= 10.Tobias Geerinckx-Rice 2021-12-13gnu: Further simplify package inputs.Ludovic Courtès 2021-12-13gnu: Simplify package inputs.Ludovic Courtès 2021-11-27gnu: wavemon: Update to 0.9.4.Tobias Geerinckx-Rice 2021-11-27gnu: hwinfo: Update to 21.78.Tobias Geerinckx-Rice 2021-10-28gnu: Add openhmd.Vinicius Monego 2021-10-17gnu: hwinfo: Update to 21.77.Tobias Geerinckx-Rice 2021-10-01gnu: Add hwinfo.Raghav Gururajan