Fix #63: create directory before un-tarring

This commit is contained in:
Michiel Borkent 2023-01-09 21:16:10 +01:00
parent 4fb0da7daf
commit 85c554e643
3 changed files with 12 additions and 2 deletions

3
.gitignore vendored
View file

@ -3,3 +3,6 @@
.lein-failures
/pom.xml
.lein-repl-history
.cache
.clj-kondo/babashka
.clj-kondo/rewrite-clj

View file

@ -1,5 +1,9 @@
# Changelog
## Unreleased
- [#63](https://github.com/babashka/pods/issues/63): create directory before un-tarring
## v0.2.0
- [#61](https://github.com/babashka/pods/issues/61): add transit as explicit JVM dependency

View file

@ -91,7 +91,10 @@
^"[Ljava.nio.file.CopyOption;"
(into-array
[java.nio.file.StandardCopyOption/REPLACE_EXISTING])))
(sh "tar" "xf" (.getPath tmp-file) "--directory" (.getPath destination-dir))
(.mkdirs destination-dir)
(let [res (sh "tar" "xf" (.getPath tmp-file) "--directory" (.getPath destination-dir))]
(when-not (zero? (:exit res))
(throw (ex-info (:err res) res))))
(.delete tmp-file)))
(defn make-executable [dest-dir executables verbose?]
@ -208,7 +211,7 @@
(cond (str/ends-with? filename ".zip")
(unzip {:zip-file cache-file
:destination-dir ddir
:verbose false})
:verbose true})
(or (str/ends-with? filename ".tgz")
(str/ends-with? filename ".tar.gz"))
(un-tgz cache-file ddir