diff --git a/backend/deps.edn b/backend/deps.edn index fbf4a4bd4..f90653661 100644 --- a/backend/deps.edn +++ b/backend/deps.edn @@ -6,7 +6,7 @@ org.clojure/clojure {:mvn/version "1.12.0"} org.clojure/tools.namespace {:mvn/version "1.5.0"} - com.github.luben/zstd-jni {:mvn/version "1.5.6-3"} + com.github.luben/zstd-jni {:mvn/version "1.5.6-6"} io.prometheus/simpleclient {:mvn/version "0.16.0"} io.prometheus/simpleclient_hotspot {:mvn/version "0.16.0"} @@ -17,7 +17,7 @@ io.prometheus/simpleclient_httpserver {:mvn/version "0.16.0"} - io.lettuce/lettuce-core {:mvn/version "6.3.2.RELEASE"} + io.lettuce/lettuce-core {:mvn/version "6.4.0.RELEASE"} java-http-clj/java-http-clj {:mvn/version "0.4.3"} funcool/yetti @@ -26,24 +26,24 @@ :git/url "https://github.com/funcool/yetti.git" :exclusions [org.slf4j/slf4j-api]} - com.github.seancorfield/next.jdbc {:mvn/version "1.3.939"} - metosin/reitit-core {:mvn/version "0.7.0"} - nrepl/nrepl {:mvn/version "1.1.2"} - cider/cider-nrepl {:mvn/version "0.48.0"} + com.github.seancorfield/next.jdbc {:mvn/version "1.3.955"} + metosin/reitit-core {:mvn/version "0.7.2"} + nrepl/nrepl {:mvn/version "1.3.0"} + cider/cider-nrepl {:mvn/version "0.50.2"} - org.postgresql/postgresql {:mvn/version "42.7.3"} - org.xerial/sqlite-jdbc {:mvn/version "3.46.0.0"} + org.postgresql/postgresql {:mvn/version "42.7.4"} + org.xerial/sqlite-jdbc {:mvn/version "3.46.1.3"} - com.zaxxer/HikariCP {:mvn/version "5.1.0"} + com.zaxxer/HikariCP {:mvn/version "6.0.0"} io.whitfin/siphash {:mvn/version "2.0.0"} buddy/buddy-hashers {:mvn/version "2.0.167"} - buddy/buddy-sign {:mvn/version "3.5.351"} + buddy/buddy-sign {:mvn/version "3.6.1-359"} com.github.ben-manes.caffeine/caffeine {:mvn/version "3.1.8"} - org.jsoup/jsoup {:mvn/version "1.17.2"} + org.jsoup/jsoup {:mvn/version "1.18.1"} org.im4java/im4java {:git/tag "1.4.0-penpot-2" :git/sha "e2b3e16" @@ -58,7 +58,7 @@ ;; Pretty Print specs pretty-spec/pretty-spec {:mvn/version "0.1.4"} - software.amazon.awssdk/s3 {:mvn/version "2.25.63"} + software.amazon.awssdk/s3 {:mvn/version "2.28.26"} } :paths ["src" "resources" "target/classes"] @@ -74,7 +74,7 @@ :build {:extra-deps - {io.github.clojure/tools.build {:git/tag "v0.10.3" :git/sha "15ead66"}} + {io.github.clojure/tools.build {:git/tag "v0.10.5" :git/sha "2a21b7a"}} :ns-default build} :test diff --git a/backend/src/app/binfile/v1.clj b/backend/src/app/binfile/v1.clj index 81f3f3b0c..aaa2f47db 100644 --- a/backend/src/app/binfile/v1.clj +++ b/backend/src/app/binfile/v1.clj @@ -222,7 +222,7 @@ (defn copy-stream! [^OutputStream output ^InputStream input ^long size] - (let [written (io/copy! input output :size size)] + (let [written (io/copy input output :size size)] (l/trace :fn "copy-stream!" :position @*position* :size size :written written ::l/sync? true) (swap! *position* + written) written)) @@ -251,11 +251,11 @@ (if (> s bfc/temp-file-threshold) (with-open [^OutputStream output (io/output-stream p)] - (let [readed (io/copy! input output :offset 0 :size s)] + (let [readed (io/copy input output :offset 0 :size s)] (l/trace :fn "read-stream*!" :expected s :readed readed :position @*position* ::l/sync? true) (swap! *position* + readed) [s p])) - [s (io/read! input :size s)]))) + [s (io/read input :size s)]))) (defmacro assert-read-label! [input expected-label] @@ -699,7 +699,7 @@ (dm/assert! "expected instance of jio/IOFactory for `input`" - (satisfies? jio/IOFactory output)) + (io/coercible? output)) (let [id (uuid/next) tp (dt/tpoint) diff --git a/backend/src/app/binfile/v2.clj b/backend/src/app/binfile/v2.clj index f135c45e6..441165d4d 100644 --- a/backend/src/app/binfile/v2.clj +++ b/backend/src/app/binfile/v2.clj @@ -190,7 +190,7 @@ [{:keys [::sto/storage] :as cfg} id] (let [sobj (sto/get-object storage id) data (with-open [input (sto/get-object-data storage sobj)] - (io/read-as-bytes input))] + (io/read input))] (l/trc :hint "write" :obj "storage-object" :id (str id) :size (:size sobj)) (write! cfg :storage-object id (meta sobj) data))) diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index bb5c29c3c..5fcfa96e8 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -236,7 +236,7 @@ (with-open [input (sto/get-object-data storage sobject)] (.putNextEntry output (ZipEntry. (str "objects/" id ext))) - (io/copy! input output (:size sobject)) + (io/copy input output :size (:size sobject)) (.closeEntry output)))))) (defn- export-file @@ -385,7 +385,7 @@ (defn- zip-entry-reader [^ZipFile input ^ZipEntry entry] (-> (zip-entry-stream input entry) - (jio/reader :encoding "UTF-8"))) + (io/reader :encoding "UTF-8"))) (defn- zip-entry-storage-content "Wraps a ZipFile and ZipEntry into a penpot storage compatible @@ -929,7 +929,7 @@ (dm/assert! "expected instance of jio/IOFactory for `input`" - (satisfies? jio/IOFactory input)) + (io/coercible? input)) (let [id (uuid/next) tp (dt/tpoint) diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index 5415e70d4..88473e899 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -1298,7 +1298,7 @@ (let [[mtype data] (parse-datauri href) size (alength ^bytes data) path (tmp/tempfile :prefix "penpot.media.download.") - written (io/write-to-file! data path :size size)] + written (io/write* path data :size size)] (when (not= written size) (ex/raise :type :internal diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 8b999d638..671967875 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -123,7 +123,7 @@ [{:keys [::db/pool]} {:keys [::session/profile-id params] :as request}] (let [profile (profile/get-profile pool profile-id) project-id (:default-project-id profile) - data (some-> params :file :path io/read-as-bytes)] + data (some-> params :file :path io/read*)] (if (and data project-id) (let [fname (str "Imported file *: " (dt/now)) diff --git a/backend/src/app/media.clj b/backend/src/app/media.clj index 4c8ae28ae..56fd53bfc 100644 --- a/backend/src/app/media.clj +++ b/backend/src/app/media.clj @@ -225,7 +225,7 @@ (letfn [(ttf->otf [data] (let [finput (tmp/tempfile :prefix "penpot.font." :suffix "") foutput (fs/path (str finput ".otf")) - _ (io/write-to-file! data finput) + _ (io/write* finput data) res (sh/sh "fontforge" "-lang=ff" "-c" (str/fmt "Open('%s'); Generate('%s')" (str finput) @@ -236,7 +236,7 @@ (otf->ttf [data] (let [finput (tmp/tempfile :prefix "penpot.font." :suffix "") foutput (fs/path (str finput ".ttf")) - _ (io/write-to-file! data finput) + _ (io/write* finput data) res (sh/sh "fontforge" "-lang=ff" "-c" (str/fmt "Open('%s'); Generate('%s')" (str finput) @@ -250,14 +250,14 @@ ;; command. (let [finput (tmp/tempfile :prefix "penpot.font." :suffix "") foutput (fs/path (str finput ".woff")) - _ (io/write-to-file! data finput) + _ (io/write* finput data) res (sh/sh "sfnt2woff" (str finput))] (when (zero? (:exit res)) foutput))) (woff->sfnt [data] (let [finput (tmp/tempfile :prefix "penpot" :suffix "") - _ (io/write-to-file! data finput) + _ (io/write* finput data) res (sh/sh "woff2sfnt" (str finput) :out-enc :bytes)] (when (zero? (:exit res)) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index c0434c82d..a49415531 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -88,22 +88,6 @@ ::yres/headers {"content-type" "application/octet-stream"} ::yres/body body}))) - - ;; {::yres/status 200 - ;; ::yres/headers {"content-type" "application/octet-stream"} - ;; ::yres/body (yres/stream-body - ;; (fn [_ output-stream] - ;; (try - ;; (-> cfg - ;; (assoc ::bf.v1/ids #{file-id}) - ;; (assoc ::bf.v1/embed-assets embed-assets) - ;; (assoc ::bf.v1/include-libraries include-libraries) - ;; (bf.v1/export-files! output-stream)) - ;; (catch Throwable cause - ;; (l/err :hint "exception on exporting file" - ;; :file-id (str file-id) - ;; :cause cause)))))})) - ;; --- Command: import-binfile (defn- import-binfile-v1 diff --git a/backend/src/app/rpc/commands/media.clj b/backend/src/app/rpc/commands/media.clj index 0a5c38e34..69265c27f 100644 --- a/backend/src/app/rpc/commands/media.clj +++ b/backend/src/app/rpc/commands/media.clj @@ -216,7 +216,7 @@ {:response-type :input-stream :sync? true}) {:keys [size mtype]} (parse-and-validate response) path (tmp/tempfile :prefix "penpot.media.download.") - written (io/write-to-file! body path :size size)] + written (io/write* path body :size size)] (when (not= written size) (ex/raise :type :internal diff --git a/backend/src/app/storage/fs.clj b/backend/src/app/storage/fs.clj index d2e6c8854..25becd69f 100644 --- a/backend/src/app/storage/fs.clj +++ b/backend/src/app/storage/fs.clj @@ -18,9 +18,13 @@ [datoteka.io :as io] [integrant.core :as ig]) (:import + java.io.InputStream + java.io.OutputStream java.nio.file.Files java.nio.file.Path)) +(set! *warn-on-reflection* true) + ;; --- BACKEND INIT (s/def ::directory ::us/string) @@ -58,9 +62,9 @@ (when-not (fs/exists? (fs/parent full)) (fs/create-dir (fs/parent full))) - (dm/with-open [src (io/input-stream content) - dst (io/output-stream full)] - (io/copy! src dst)) + (with-open [^InputStream src (io/input-stream content)] + (with-open [^OutputStream dst (io/output-stream full)] + (io/copy src dst))) object)) @@ -78,8 +82,8 @@ (defmethod impl/get-object-bytes :fs [backend object] - (dm/with-open [input (impl/get-object-data backend object)] - (io/read-as-bytes input))) + (with-open [^InputStream input (impl/get-object-data backend object)] + (io/read input))) (defmethod impl/get-object-url :fs [{:keys [::uri] :as backend} {:keys [id] :as object} _] diff --git a/backend/test/backend_tests/rpc_font_test.clj b/backend/test/backend_tests/rpc_font_test.clj index f20796943..91ee15f1f 100644 --- a/backend/test/backend_tests/rpc_font_test.clj +++ b/backend/test/backend_tests/rpc_font_test.clj @@ -28,8 +28,7 @@ font-id (uuid/custom 10 1) ttfdata (-> (io/resource "backend_tests/test_files/font-1.ttf") - io/input-stream - io/read-as-bytes) + (io/read*)) params {::th/type :create-font-variant ::rpc/profile-id (:id prof) @@ -65,8 +64,7 @@ font-id (uuid/custom 10 1) data (-> (io/resource "backend_tests/test_files/font-1.woff") - io/input-stream - io/read-as-bytes) + (io/read*)) params {::th/type :create-font-variant ::rpc/profile-id (:id prof) @@ -100,12 +98,10 @@ font-id (uuid/custom 10 1) data1 (-> (io/resource "backend_tests/test_files/font-1.woff") - io/input-stream - io/read-as-bytes) + (io/read*)) data2 (-> (io/resource "backend_tests/test_files/font-2.woff") - io/input-stream - io/read-as-bytes)] + (io/read*))] ;; Create front variant (let [params {::th/type :create-font-variant @@ -162,12 +158,10 @@ font-id (uuid/custom 10 1) data1 (-> (io/resource "backend_tests/test_files/font-1.woff") - io/input-stream - io/read-as-bytes) + (io/read*)) data2 (-> (io/resource "backend_tests/test_files/font-2.woff") - io/input-stream - io/read-as-bytes)] + (io/read*))] ;; Create front variant (let [params {::th/type :create-font-variant @@ -224,12 +218,10 @@ font-id (uuid/custom 10 1) data1 (-> (io/resource "backend_tests/test_files/font-1.woff") - io/input-stream - io/read-as-bytes) + (io/read*)) data2 (-> (io/resource "backend_tests/test_files/font-2.woff") - io/input-stream - io/read-as-bytes) + (io/read*)) params1 {::th/type :create-font-variant ::rpc/profile-id (:id prof) :team-id team-id diff --git a/backend/test/backend_tests/rpc_media_test.clj b/backend/test/backend_tests/rpc_media_test.clj index 5147b1e12..748c72683 100644 --- a/backend/test/backend_tests/rpc_media_test.clj +++ b/backend/test/backend_tests/rpc_media_test.clj @@ -47,11 +47,7 @@ (t/is (sto/object? mobj1)) (t/is (sto/object? mobj2)) (t/is (= 122785 (:size mobj1))) - ;; This is because in ubuntu 21.04 generates different - ;; thumbnail that in ubuntu 22.04. This hack should be removed - ;; when we all use the ubuntu 22.04 devenv image. - (t/is (or (= 3302 (:size mobj2)) - (= 3303 (:size mobj2)))))))) + (t/is (= 3302 (:size mobj2))))))) (t/deftest media-object-upload (let [prof (th/create-profile* 1) @@ -166,11 +162,7 @@ (t/is (sto/object? mobj1)) (t/is (sto/object? mobj2)) (t/is (= 122785 (:size mobj1))) - ;; This is because in ubuntu 21.04 generates different - ;; thumbnail that in ubuntu 22.04. This hack should be removed - ;; when we all use the ubuntu 22.04 devenv image. - (t/is (or (= 3302 (:size mobj2)) - (= 3303 (:size mobj2)))))))) + (t/is (= 3302 (:size mobj2))))))) (t/deftest media-object-upload-command (let [prof (th/create-profile* 1) diff --git a/backend/test/backend_tests/storage_test.clj b/backend/test/backend_tests/storage_test.clj index 7e21ec970..e40f61333 100644 --- a/backend/test/backend_tests/storage_test.clj +++ b/backend/test/backend_tests/storage_test.clj @@ -202,8 +202,7 @@ :is-shared false}) ttfdata (-> (io/resource "backend_tests/test_files/font-1.ttf") - io/input-stream - io/read-as-bytes) + (io/read*)) mfile {:filename "sample.jpg" :path (th/tempfile "backend_tests/test_files/sample.jpg") diff --git a/common/deps.edn b/common/deps.edn index e0d27dd98..d526bad78 100644 --- a/common/deps.edn +++ b/common/deps.edn @@ -38,7 +38,7 @@ funcool/datoteka {:git/tag "4.0.0" - :git/sha "8dcb8fc" + :git/sha "3372f3a" :git/url "https://github.com/funcool/datoteka"} lambdaisland/uri {:mvn/version "1.19.155" @@ -72,7 +72,7 @@ :build {:extra-deps - {io.github.clojure/tools.build {:git/tag "v0.10.3" :git/sha "15ead66"}} + {io.github.clojure/tools.build {:git/tag "v0.10.5" :git/sha "2a21b7a"}} :ns-default build} :test