Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fn to check for modified resource files
(def some-file-resources-modified?
"Returns true iff any of the files backing given resources have changed
since this function was last called."
(let [times (atom {})]
(fn modified?
([resource-name & more] (some modified? (cons resource-name more)))
([resource-name]
(when-let [^File file (try (->> resource-name io/resource io/file)
(catch Exception _ nil))]
(let [last-modified (.lastModified file)]
(let [file-name (str file)
modified? (> last-modified (@times file-name 0))]
(when modified? (swap! times assoc file-name last-modified))
modified?)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.