clean up autosave a little

guard more of the filesystem manipulations with
handlers and log errors instead of letting them
be raised and show up as internal errors

related to PR 13403

original commit: 94b54db11823b4683234424174aca2836d422204
This commit is contained in:
Robby Findler 2013-01-03 13:51:14 -06:00
parent 25d13bbd7d
commit 67467bc32e

View File

@ -552,9 +552,11 @@
(let ([back-name (path-utils:generate-backup-name name)]) (let ([back-name (path-utils:generate-backup-name name)])
(when (or (not (file-exists? back-name)) (when (or (not (file-exists? back-name))
(file-old? back-name)) (file-old? back-name))
(with-handlers ([exn:fail?
(λ (exn)
(log-debug "failed to clean up autosave file.1: ~a" back-name))])
(when (file-exists? back-name) (when (file-exists? back-name)
(delete-file back-name)) (delete-file back-name))
(with-handlers ([(λ (x) #t) void])
(copy-file name back-name))))) (copy-file name back-name)))))
(inner (void) on-save-file name format)) (inner (void) on-save-file name format))
(define/augment (on-close) (define/augment (on-close)
@ -635,9 +637,13 @@
(define/public (remove-autosave) (define/public (remove-autosave)
(when auto-saved-name (when auto-saved-name
(when (file-exists? auto-saved-name) (when (file-exists? auto-saved-name)
(delete-file auto-saved-name)) (with-handlers ([exn:fail?
(set! auto-saved-name #f))) (λ (exn)
(super-instantiate ()) (log-debug "failed to clean up autosave file.2: ~a"
auto-saved-name))])
(delete-file auto-saved-name)
(set! auto-saved-name #f)))))
(super-new)
(autosave:register this))) (autosave:register this)))
(define info<%> (interface (basic<%>))) (define info<%> (interface (basic<%>)))