Closed arichiardi closed 7 years ago
I tried to upgrade to [org.apache.commons/commons-compress "1.13"]
, no luck.
This is ugly but works (shall I PR by having a custom implementation for GZip only?):
(defn decompress-file [in out-dir & [{:keys [compression-format archive-format]}]]
(with-open [is (if (.endsWith in ".gz")
(-> (io/input-stream in)
(try-decompress-stream {:format compression-format}))
(-> (io/input-stream in)
(try-decompress-stream {:format compression-format})
(unpackage-stream {:format archive-format})))]
(if (.endsWith in ".gz")
(let [target (io/file out-dir (.getName (io/file in)))]
(println target)
(io/make-parents target)
(io/copy is target))
(let [count (loop [i 0
entry (.getNextEntry is)]
(if entry
(if-not (.isDirectory entry)
(let [target (io/file out-dir (.getName entry))]
(io/make-parents target)
; After .getNextEntry the stream points to the specific archive entry
(io/copy is target)
(recur (inc i) (.getNextEntry is)))
(recur i (.getNextEntry is)))
i))]
(util/info (format "Extracted %d files\n" count))))))
BTW I am doing this because I am trying to contribute a package and I want to minify and gz the main file and the gzipped file in one unique file if possible.
I am trying to decompress a
.gz
file using the provided tasks (no tar).Unfotunately, it blows:
Debugging it, basically the problem is that this guy creates a
org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream
which does not support marking, which is weird.The
ArchiveStreamFactory
has the requirement, see here.Thoughts?