summaryrefslogtreecommitdiff
path: root/sly/live-reload.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-11-30 21:34:26 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-11-30 21:34:26 -0500
commit91f825fec2594c9ce9f0e4cbaecd1ad1315ae462 (patch)
tree77498f934f6bb3bc8fbf568e49a9b21c9ee17a96 /sly/live-reload.scm
parent7c60995c826a50844a961d648bca45d6f2e34233 (diff)
live-reload: Protect against deleted files and also check ctime.
* sly/live-reload.scm (live-reload): Check if file exists before making stat call. Check ctime in addition to mtime.
Diffstat (limited to 'sly/live-reload.scm')
-rw-r--r--sly/live-reload.scm7
1 files changed, 5 insertions, 2 deletions
diff --git a/sly/live-reload.scm b/sly/live-reload.scm
index 78c4cf7..ed4d94a 100644
--- a/sly/live-reload.scm
+++ b/sly/live-reload.scm
@@ -41,13 +41,16 @@ filename string."
(apply proc filename args))
(define (current-mtime)
- (stat:mtime (stat filename)))
+ (let ((info (stat filename)))
+ (max (stat:mtime info) (stat:ctime info))))
(let ((asset (make-signal (load-asset))))
(coroutine
(let loop ((last-mtime (current-mtime)))
(wait live-reload-interval)
- (let ((mtime (current-mtime)))
+ (let ((mtime (if (file-exists? filename)
+ (current-mtime)
+ last-mtime)))
(when (> mtime last-mtime)
(signal-set! asset (load-asset)))
(loop mtime))))