mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 06:58:58 -05:00
🔥 Remove internal file data blob format v2
This commit is contained in:
parent
e0ac583aba
commit
675a07bac6
3 changed files with 8 additions and 31 deletions
|
@ -3,6 +3,12 @@
|
||||||
## :rocket: Next
|
## :rocket: Next
|
||||||
|
|
||||||
### :boom: Breaking changes & Deprecations
|
### :boom: Breaking changes & Deprecations
|
||||||
|
|
||||||
|
- Removed the support for v2 internal file data blob format. This
|
||||||
|
version has never been documented nor set as default value so
|
||||||
|
technicaly this is not a breaking change because we are removing
|
||||||
|
a "private API".
|
||||||
|
|
||||||
### :sparkles: New features
|
### :sparkles: New features
|
||||||
|
|
||||||
- Add team hero in projects dashboard [Taiga #3863](https://tree.taiga.io/project/penpot/us/3863)
|
- Add team hero in projects dashboard [Taiga #3863](https://tree.taiga.io/project/penpot/us/3863)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
;; Logging
|
;; Logging
|
||||||
org.zeromq/jeromq {:mvn/version "0.5.2"}
|
org.zeromq/jeromq {:mvn/version "0.5.2"}
|
||||||
|
|
||||||
com.taoensso/nippy {:mvn/version "3.1.1"}
|
|
||||||
com.github.luben/zstd-jni {:mvn/version "1.5.2-3"}
|
com.github.luben/zstd-jni {:mvn/version "1.5.2-3"}
|
||||||
org.clojure/data.fressian {:mvn/version "1.0.0"}
|
org.clojure/data.fressian {:mvn/version "1.0.0"}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.transit :as t]
|
[app.common.transit :as t]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.util.fressian :as fres]
|
[app.util.fressian :as fres])
|
||||||
[taoensso.nippy :as n])
|
|
||||||
(:import
|
(:import
|
||||||
java.io.ByteArrayInputStream
|
java.io.ByteArrayInputStream
|
||||||
java.io.ByteArrayOutputStream
|
java.io.ByteArrayOutputStream
|
||||||
|
@ -27,21 +26,18 @@
|
||||||
(def lz4-factory (LZ4Factory/fastestInstance))
|
(def lz4-factory (LZ4Factory/fastestInstance))
|
||||||
|
|
||||||
(declare decode-v1)
|
(declare decode-v1)
|
||||||
(declare decode-v2)
|
|
||||||
(declare decode-v3)
|
(declare decode-v3)
|
||||||
(declare decode-v4)
|
(declare decode-v4)
|
||||||
(declare encode-v1)
|
(declare encode-v1)
|
||||||
(declare encode-v2)
|
|
||||||
(declare encode-v3)
|
(declare encode-v3)
|
||||||
(declare encode-v4)
|
(declare encode-v4)
|
||||||
|
|
||||||
(defn encode
|
(defn encode
|
||||||
([data] (encode data nil))
|
([data] (encode data nil))
|
||||||
([data {:keys [version]}]
|
([data {:keys [version]}]
|
||||||
(let [version (or version (cf/get :default-blob-version 3))]
|
(let [version (or version (cf/get :default-blob-version 4))]
|
||||||
(case (long version)
|
(case (long version)
|
||||||
1 (encode-v1 data)
|
1 (encode-v1 data)
|
||||||
2 (encode-v2 data)
|
|
||||||
3 (encode-v3 data)
|
3 (encode-v3 data)
|
||||||
4 (encode-v4 data)
|
4 (encode-v4 data)
|
||||||
(throw (ex-info "unsupported version" {:version version}))))))
|
(throw (ex-info "unsupported version" {:version version}))))))
|
||||||
|
@ -55,7 +51,6 @@
|
||||||
ulen (.readInt dis)]
|
ulen (.readInt dis)]
|
||||||
(case version
|
(case version
|
||||||
1 (decode-v1 data ulen)
|
1 (decode-v1 data ulen)
|
||||||
2 (decode-v2 data ulen)
|
|
||||||
3 (decode-v3 data ulen)
|
3 (decode-v3 data ulen)
|
||||||
4 (decode-v4 data ulen)
|
4 (decode-v4 data ulen)
|
||||||
(throw (ex-info "unsupported version" {:version version}))))))
|
(throw (ex-info "unsupported version" {:version version}))))))
|
||||||
|
@ -84,29 +79,6 @@
|
||||||
(.decompress ^LZ4FastDecompressor dcp cdata 6 ^bytes udata 0 ulen)
|
(.decompress ^LZ4FastDecompressor dcp cdata 6 ^bytes udata 0 ulen)
|
||||||
(t/decode udata {:type :json})))
|
(t/decode udata {:type :json})))
|
||||||
|
|
||||||
(defn- encode-v2
|
|
||||||
[data]
|
|
||||||
(let [data (n/fast-freeze data)
|
|
||||||
dlen (alength ^bytes data)
|
|
||||||
mlen (Zstd/compressBound dlen)
|
|
||||||
cdata (byte-array mlen)
|
|
||||||
clen (Zstd/compressByteArray ^bytes cdata 0 mlen
|
|
||||||
^bytes data 0 dlen
|
|
||||||
8)]
|
|
||||||
(with-open [^ByteArrayOutputStream baos (ByteArrayOutputStream. (+ (alength cdata) 2 4))
|
|
||||||
^DataOutputStream dos (DataOutputStream. baos)]
|
|
||||||
(.writeShort dos (short 2)) ;; version number
|
|
||||||
(.writeInt dos (int dlen))
|
|
||||||
(.write dos ^bytes cdata (int 0) clen)
|
|
||||||
(.toByteArray baos))))
|
|
||||||
|
|
||||||
(defn- decode-v2
|
|
||||||
[^bytes cdata ^long ulen]
|
|
||||||
(let [udata (byte-array ulen)]
|
|
||||||
(Zstd/decompressByteArray ^bytes udata 0 ulen
|
|
||||||
^bytes cdata 6 (- (alength cdata) 6))
|
|
||||||
(n/fast-thaw udata)))
|
|
||||||
|
|
||||||
(defn- encode-v3
|
(defn- encode-v3
|
||||||
[data]
|
[data]
|
||||||
(let [data (t/encode data {:type :json})
|
(let [data (t/encode data {:type :json})
|
||||||
|
|
Loading…
Add table
Reference in a new issue