Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unzip to take an InputStream to unzip #125

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/babashka/fs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require [clojure.java.io :as io]
[clojure.string :as str]
[clojure.walk :as walk])
(:import [java.io File]
(:import [java.io File InputStream]
[java.net URI]
[java.nio.file StandardOpenOption CopyOption
#?@(:bb [] :clj [DirectoryStream]) #?@(:bb [] :clj [DirectoryStream$Filter])
Expand Down Expand Up @@ -966,11 +966,11 @@
([zip-file dest] (unzip zip-file dest nil))
([zip-file dest {:keys [replace-existing]}]
(let [output-path (as-path dest)
zip-file (as-path zip-file)
_ (create-dirs dest)
cp-opts (->copy-opts replace-existing nil nil nil)]
(with-open
[fis (Files/newInputStream zip-file (into-array java.nio.file.OpenOption []))
[fis (if (instance? InputStream zip-file) zip-file
(Files/newInputStream (as-path zip-file) (into-array java.nio.file.OpenOption [])))
zis (ZipInputStream. fis)]
(loop []
(let [entry (.getNextEntry zis)]
Expand Down
Loading