This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-28
Channels
- # asami (5)
- # babashka (44)
- # beginners (22)
- # biff (7)
- # clerk (86)
- # clj-kondo (5)
- # clojure (33)
- # clojure-europe (8)
- # clr (6)
- # community-development (2)
- # fulcro (20)
- # graalvm (5)
- # graphql (1)
- # hugsql (3)
- # integrant (5)
- # java (11)
- # joyride (2)
- # leiningen (4)
- # malli (12)
- # nbb (15)
- # off-topic (28)
- # pathom (23)
- # reitit (8)
- # releases (1)
- # sci (6)
- # shadow-cljs (39)
- # tools-deps (15)
- # tree-sitter (1)
This works in a Dockerfile. I just thought that was neat. Idk if it's very useful yet though.
SHELL ["bb", "-e"]
RUN (spit "config.yml" (cheshire.core/generate-string (clojure.edn/read-string (slurp "config.edn"))))
I think I want to call last-modified
but it's private. https://github.com/babashka/fs/blob/8a8bfa618be6f0c1b21be0daafd1887e2a4f5c44/src/babashka/fs.cljc#L867 I want to compare against the LastTagTime of a docker image to know if I should rebuild or skip. This seems like the perfect function for that.
I’d probably use the .lastModified method for File via interop than trying to get the private fn to work if I’m just comparing times.
@U04V15CAJ that would not support comparing with a timestamp right? it needs another file? i think the use case is to compare with a timestamp
@UPD88PGNT also just found out https://github.com/babashka/fs/blob/master/API.md#babashka.fs/last-modified-time is already there.
Right, modified-since
is closest to what I want since it can take a directory and walk it recursively to find the latest modified time. I don't want to compare against another file though, I want to compare it to another time. last-modified-time
only works on one file so I'd have to recurse myself. https://github.com/babashka/fs/blob/8a8bfa618be6f0c1b21be0daafd1887e2a4f5c44/src/babashka/fs.cljc#L873-L875
maybe we could change modified-since to also accept a time (or times) to compare against
I don't think there is a need to copy last-modified since you can use fs/last-modified-time
last-modified-time
only works against one file, right? I was trying to reuse the code that finds the latest of many files in a folder.
you can do that like this:
$ bb -e '(map (comp fs/file-time->millis fs/last-modified-time) (fs/glob "." "**"))'
(1674917980174 1674917980162 1674917980162 1674917980172 1674917980171 1674917980171 1674917980172
$ bb -e '(apply max 0 (map (comp fs/file-time->millis fs/last-modified-time) (fs/glob "." "**")))'
1674917980175
(fs/glob "." "**")
gives:
java.nio.file.NoSuchFileException: c:\Users\me\containers\homer\out\bin\arch
at sun.nio.fs.WindowsFileSystemProvider.isHidden (WindowsFileSystemProvider.java:471)
emacs says that arch is "a symlink to a nonexistent target"I just reproduced it by making a symlink to a file and then deleting the file. e.g. I made the file target
, made a symlink (in cmd.exe mklink link target
), deleted target
, and then in my bb nrepl (fs/glob "." "**")
gives
java.nio.file.NoSuchFileException: c:\Users\me\test\link
at sun.nio.fs.WindowsFileSystemProvider.isHidden (WindowsFileSystemProvider.java:471)
lrwxr-xr-x 1 borkdude wheel 1 Jan 28 20:07 a -> b
drwxrwxrwt 51 root wheel 1632 Jan 28 20:06 ..
borkdude@m1 /tmp/test-link $ bb -e '(fs/hidden? "a")'
false
All fs is calling here is https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isHidden(java.nio.file.Path)