Check that cache dir is writable before writing (#47)

...pod metadata cache file
This commit is contained in:
Wes Morgan 2022-05-14 10:44:00 -06:00 committed by GitHub
parent c2d6ba847c
commit aee5337cef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,8 @@
(:require [babashka.pods.impl :as impl]
[sci.core :as sci]
[clojure.java.io :as io]
[babashka.pods.impl.resolver :as resolver])
[babashka.pods.impl.resolver :as resolver]
[babashka.fs :as fs])
(:import (java.io PushbackInputStream File)))
(set! *warn-on-reflection* true)
@ -45,8 +46,9 @@
cache-file (when cache (metadata-cache-file bb-edn-file pod-spec opts))]
(when cache-file
(io/make-parents cache-file)
(with-open [w (io/output-stream cache-file)]
(impl/write w metadata)))
(when (fs/writable? (fs/parent cache-file))
(with-open [w (io/output-stream cache-file)]
(impl/write w metadata))))
metadata))
(defn load-pod-metadata