It appears that a `filesystem-change-evt` created with a path referring to
a symbolic link effectively watches the target of the link for changes, not
the link itself. For example, deleting the link and creating a new link
that points to a different target does not cause the event to become ready
for synchronization. (I've included a demonstration program at the end of
this email.)

If this is the expected behavior, it seems like it would be worth
mentioning in the documentation for `filesystem-change-evt`.


#lang racket

;; Displays "Orig target changed".
;; Tested on Mac OS and Ubuntu.
;; Would need to be changed to test on Windows
;; because Windows only has directory-level precision.

(define basedir
  (make-temporary-file "rkttmp~a" 'directory))

(define a-path
  (build-path basedir "a"))

(define b-path
  (build-path basedir "b"))

(define link-path
  (build-path basedir "link"))

(define (main)
  (let/ec return
    (write-to-file 'a a-path)
    (write-to-file 'b b-path)
    (make-file-or-directory-link a-path link-path)
    (define evt
      (filesystem-change-evt link-path))
    (define (check-evt message)
      (sync/timeout 0
                    (handle-evt evt
                                (λ (_)
                                  (displayln message)
                                  (return (void))))))
     (λ ()
       (check-evt "At start")
       (delete-file link-path)
       (check-evt "Link deleted")
       (make-file-or-directory-link b-path link-path)
       (check-evt "New link created")
       (write-to-file 'changed b-path #:exists 'truncate/replace)
       (check-evt "New target changed")
       (write-to-file 'changed a-path #:exists 'truncate/replace)
       (check-evt "Orig target changed")
       (displayln "Shouldn't get here"))
     (λ ()
       (filesystem-change-evt-cancel evt)))))

 (λ ()
    #:must-exist? #f)))

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to