From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 43366@debbugs.gnu.org
Cc: Fredrik Salomonsson <plattfot@gmail.com>,
Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: bug#43366: [PATCH core-updates] utils: Do not raise exceptions in delete-file-recursively.
Date: Tue, 15 Sep 2020 00:08:37 -0400 [thread overview]
Message-ID: <20200915040837.26098-1-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <87v9gi5ou8.fsf@posteo.net>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=yes, Size: 2196 bytes --]
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>
---
guix/build/utils.scm | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 0a04032834..fbf4f2d61a 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.
;;;
@@ -366,6 +367,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
@@ -376,10 +387,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)
--
2.28.0
next prev parent reply other threads:[~2020-09-15 4:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-13 3:37 bug#43366: "error: rmdir: Device or resource busy" when using btrfs Fredrik Salomonsson
2020-09-15 4:08 ` Maxim Cournoyer [this message]
2020-09-15 4:15 ` Maxim Cournoyer
2020-09-15 18:15 ` Fredrik Salomonsson
2020-10-08 15:44 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200915040837.26098-1-maxim.cournoyer@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=43366@debbugs.gnu.org \
--cc=plattfot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).