Re: [PATCH shepherd v2] support: Ignore errors in mkdir-p when the directories exist.

2016-02-06 Thread Ludovic Courtès
David Michael  skribis:

> * modules/shepherd/support.scm (mkdir-p): Don't throw errors when
>   mkdir fails but the directory exists afterwards.

[...]

> - (if (= EEXIST (system-error-errno args))
> + (if (and (file-exists? path)
> +  (eq? (stat:type (stat path)) 'directory))

This systematically does two ‘stat’ calls and can raise an exception if
PATH does not exist.

I’ve adjusted it in commit 2cf such that on GNU/Linux there’s no
extra ‘stat’.

Thanks!

Ludo’.



[PATCH shepherd v2] support: Ignore errors in mkdir-p when the directories exist.

2016-02-05 Thread David Michael
* modules/shepherd/support.scm (mkdir-p): Don't throw errors when
  mkdir fails but the directory exists afterwards.
---
 modules/shepherd/support.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index 9bc5f5d..4059770 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -172,7 +172,8 @@ output port, and PROC's result is returned."
  (mkdir path))
  (loop tail path))
(lambda args
- (if (= EEXIST (system-error-errno args))
+ (if (and (file-exists? path)
+  (eq? (stat:type (stat path)) 'directory))
  (loop tail path)
  (apply throw args))
   (() #t
-- 
2.5.0