From 342fb612085b6e294eb9eb166f26617f8a35bde8 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Mon, 23 Nov 2009 17:20:41 +0000 Subject: [PATCH] There is a race condition in this code. This doesn't totally fix it, if another process is creating and deleting the directory quickly, but it will help. svn: r16996 --- collects/scheme/file.ss | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/collects/scheme/file.ss b/collects/scheme/file.ss index 624746de0c..6075feccb4 100644 --- a/collects/scheme/file.ss +++ b/collects/scheme/file.ss @@ -65,7 +65,13 @@ (not (directory-exists? base))) (make-directory* base)) (unless (directory-exists? dir) - (make-directory dir)))) + (with-handlers ([exn:fail:filesystem? + (lambda (x) + (unless (and (regexp-match #rx"cannot make directory:.+File exists" + (exn-message x)) + (directory-exists? dir)) + (raise x)))]) + (make-directory dir))))) (define (make-temporary-file [template "mztmp~a"] [copy-from #f] [base-dir #f]) (with-handlers ([exn:fail:contract?