boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 182 forks source link

AccessDeniedException kills the filesystem watcher #546

Open schmir opened 7 years ago

schmir commented 7 years ago

The filesystem watcher should never die. In 2.7.0 issue #477 has been fixed. When creating a file with mode 000, the filesystem watcher dies (i.e. touch foo.clj; chmod 000 foo.clj)

dev=> Uncaught exception in thread Thread-15:
                           java.lang.Thread.run                  Thread.java:  745
                                            ...                                   
                        boot.core/watch-dirs/fn                     core.clj:  751
             boot.core/set-user-dirs!/on-change                     core.clj:  194
                      boot.core/sync-user-dirs!                     core.clj:  139
                                            ...                                   
                               boot.core/patch!                     core.clj:  725
                                            ...                                   
                         boot.filesystem/patch!               filesystem.clj:  200
                                            ...                                   
                          boot.filesystem/copy!               filesystem.clj:  163
                       java.nio.file.Files.copy                   Files.java: 1274
         sun.nio.fs.UnixFileSystemProvider.copy  UnixFileSystemProvider.java:  253
                   sun.nio.fs.UnixCopyFile.copy            UnixCopyFile.java:  581
               sun.nio.fs.UnixCopyFile.copyFile            UnixCopyFile.java:  230
  sun.nio.fs.UnixException.rethrowAsIOException           UnixException.java:  107
  sun.nio.fs.UnixException.rethrowAsIOException           UnixException.java:  102
sun.nio.fs.UnixException.translateToIOException           UnixException.java:   84
java.nio.file.AccessDeniedException: resources/foo2
    file: "resources/foo2"

It's easy to fix that case like the fix for #477, but I think it would also make sense to catch exceptions in the outer filesystem watcher loop in order to make it a bit more robust.

(in my case some emacs backup/lock files kill the watcher)

alandipert commented 7 years ago

Thanks @schmir I agree. A PR would be most welcome here.

Although in case you're not aware, you can configure emacs to store lock files elsewhere.