Scribble with-compile-output fix

This commit is contained in:
Kevin Tew 2011-01-20 14:28:27 -07:00
parent 128fedaceb
commit a42ea71113
3 changed files with 17 additions and 3 deletions

View File

@ -180,7 +180,13 @@
(set! ok? #t)))
(lambda ()
(if ok?
(rename-file-or-directory tmp-path path #t)
(if (eq? (system-type) 'windows)
(let ([tmp-path2 (make-temporary-file "tmp~a" #f (path-only path))])
(with-handlers ([exn:fail:filesystem? void])
(rename-file-or-directory path tmp-path2 #t))
(rename-file-or-directory tmp-path path #t)
(try-delete-file tmp-path2))
(rename-file-or-directory tmp-path path #t))
(try-delete-file tmp-path))))))
(define (get-source-sha1 p)

View File

@ -311,7 +311,15 @@ returns, @racket[with-compile-output] renames @racket[tmp-path] to
exception. Breaks are managed so that the @racket[port] is reliably
closed and the @racket[tmp-path] file is reliably deleted if there's a
break. The result of @racket[proc] is the result of the
@racket[with-compile-output] call.}
@racket[with-compile-output] call.
Windows prevents programs from overwriting files that are open. As a result,
@racket[with-compile-output] calls to @racket[rename-file-or-directory] will
fail if the destination file argument is an open file. Windows, however, does
allow you to rename an open file. To avoid overwriting open files
windows, @racket[with-compile-output] creates a second temporary file
@racket[tmp-path2], renames @racket[p] to @racket[tmp-path2], renames
@racket[tmp-path] to @racket[p], and finally deletes @racket[tmp-path2].}
@defparam[parallel-lock-client proc ([command (or/c 'lock 'unlock)] [zo-path bytes?] . -> . boolean?)]{

View File

@ -643,7 +643,7 @@
(let ([data (list (get-compiled-file-sha1 src-zo)
(get-compiled-file-sha1 renderer-path)
(get-file-sha1 css-path))])
(with-output-to-file stamp-file #:exists 'truncate/replace (lambda () (write data)))
(with-compile-output stamp-file (lambda (out tmp-filename) (write data out)))
(let ([m (max aux-time src-time)])
(unless (equal? m +inf.0)
(file-or-directory-modify-seconds stamp-file m)))))