bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 2a6791202858c637a3f49f47166d5d835d68031c
parent 4291016987898677abfa38158a1b3f4bb262af23
Author: Matthew Flatt <mflatt@racket-lang.org>
Date:   Fri,  9 May 2014 09:15:07 -0600

scribble: discard partial output on exception

This change avoids the problem of a bad "index.html" on a doucment
rendering error, where the presense of an "index.html" would count
as successes on a retry.

original commit: e4e8a69e06863b423f4b7b716b369b002c2deea1

Diffstat:
Mpkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt | 27++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt @@ -247,6 +247,18 @@ (define (part-parent d ri) (collected-info-parent (part-collected-info d ri))) +(define (with-output-to-file/clean fn thunk) + ;; We use 'replace instead of the usual 'truncate/replace + ;; to avoid problems where a filename changes only in case, + ;; in which case some platforms will see the old file + ;; as matching the new name, while others don't. Replacing + ;; the file syncs the case with the current uses. + (with-handlers ([exn? ; delete file on breaks, too + (lambda (exn) + (delete-file fn) + (raise exn))]) + (with-output-to-file fn #:exists 'replace thunk))) + ;; ---------------------------------------- ;; main mixin @@ -1808,8 +1820,9 @@ ;; install files for each directory (install-extra-files ds) (let ([fn (build-path fn "index.html")]) - (with-output-to-file fn #:exists 'truncate/replace - (lambda () (render-one d ri fn)))))) + (with-output-to-file/clean + fn + (lambda () (render-one d ri fn)))))) ds fns)) @@ -1841,13 +1854,9 @@ (if p (build-path (current-subdirectory) p) (current-subdirectory)))]) - ;; We use 'replace instead of the usual 'truncate/replace - ;; to avoid problems where a filename changes only in case, - ;; in which case some platforms will see the old file - ;; as matching the new name, while others don't. Replacing - ;; the file syncs the case with the current uses. - (with-output-to-file full-path #:exists 'replace - (lambda () (render-one-part d ri full-path number))) + (with-output-to-file/clean + full-path + (lambda () (render-one-part d ri full-path number))) null)) (parameterize ([on-separate-page-ok #t]) ;; Normal section render