mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 23:46:11 +02:00
🐛 Fix issue with encoding/decoding thumbnails on binfile-v3 format
This commit is contained in:
parent
f78f843f7c
commit
2d1158efa3
1 changed files with 12 additions and 6 deletions
|
@ -296,7 +296,7 @@
|
||||||
|
|
||||||
(doseq [thumbnail thumbnails]
|
(doseq [thumbnail thumbnails]
|
||||||
(let [data (cth/parse-object-id (:object-id thumbnail))
|
(let [data (cth/parse-object-id (:object-id thumbnail))
|
||||||
path (str "files/" file-id "/thumbnails/" (:page-id data)
|
path (str "files/" file-id "/thumbnails/" (:tag data) "/" (:page-id data)
|
||||||
"/" (:frame-id data) ".json")
|
"/" (:frame-id data) ".json")
|
||||||
data (-> data
|
data (-> data
|
||||||
(assoc :media-id (:media-id thumbnail))
|
(assoc :media-id (:media-id thumbnail))
|
||||||
|
@ -459,11 +459,12 @@
|
||||||
|
|
||||||
(defn- match-thumbnail-entry-fn
|
(defn- match-thumbnail-entry-fn
|
||||||
[file-id]
|
[file-id]
|
||||||
(let [pattern (str "^files/" file-id "/thumbnails/([^/]+)/([^/]+).json$")
|
(let [pattern (str "^files/" file-id "/thumbnails/([^/]+)/([^/]+)/([^/]+).json$")
|
||||||
pattern (re-pattern pattern)]
|
pattern (re-pattern pattern)]
|
||||||
(fn [entry]
|
(fn [entry]
|
||||||
(when-let [[_ page-id frame-id] (re-matches pattern (zip-entry-name entry))]
|
(when-let [[_ tag page-id frame-id] (re-matches pattern (zip-entry-name entry))]
|
||||||
{:entry entry
|
{:entry entry
|
||||||
|
:tag tag
|
||||||
:page-id (parse-uuid page-id)
|
:page-id (parse-uuid page-id)
|
||||||
:frame-id (parse-uuid frame-id)
|
:frame-id (parse-uuid frame-id)
|
||||||
:file-id file-id}))))
|
:file-id file-id}))))
|
||||||
|
@ -603,12 +604,13 @@
|
||||||
(defn- read-file-thumbnails
|
(defn- read-file-thumbnails
|
||||||
[{:keys [::input ::file-id ::entries] :as cfg}]
|
[{:keys [::input ::file-id ::entries] :as cfg}]
|
||||||
(->> (keep (match-thumbnail-entry-fn file-id) entries)
|
(->> (keep (match-thumbnail-entry-fn file-id) entries)
|
||||||
(reduce (fn [result {:keys [page-id frame-id entry]}]
|
(reduce (fn [result {:keys [page-id frame-id tag entry]}]
|
||||||
(let [object (->> (read-entry input entry)
|
(let [object (->> (read-entry input entry)
|
||||||
(decode-file-thumbnail)
|
(decode-file-thumbnail)
|
||||||
(validate-file-thumbnail))]
|
(validate-file-thumbnail))]
|
||||||
(if (and (= frame-id (:frame-id object))
|
(if (and (= frame-id (:frame-id object))
|
||||||
(= page-id (:page-id object)))
|
(= page-id (:page-id object))
|
||||||
|
(= tag (:tag object)))
|
||||||
(conj result object)
|
(conj result object)
|
||||||
result)))
|
result)))
|
||||||
[])
|
[])
|
||||||
|
@ -788,7 +790,6 @@
|
||||||
media-id (bfc/lookup-index (:media-id item))
|
media-id (bfc/lookup-index (:media-id item))
|
||||||
object-id (-> (assoc item :file-id file-id)
|
object-id (-> (assoc item :file-id file-id)
|
||||||
(cth/fmt-object-id))
|
(cth/fmt-object-id))
|
||||||
|
|
||||||
params {:file-id file-id
|
params {:file-id file-id
|
||||||
:object-id object-id
|
:object-id object-id
|
||||||
:tag (:tag item)
|
:tag (:tag item)
|
||||||
|
@ -902,6 +903,11 @@
|
||||||
(export-files cfg)
|
(export-files cfg)
|
||||||
(export-storage-objects cfg)))))
|
(export-storage-objects cfg)))))
|
||||||
|
|
||||||
|
(catch java.util.zip.ZipException cause
|
||||||
|
(vreset! cs cause)
|
||||||
|
(vreset! ab true)
|
||||||
|
(throw cause))
|
||||||
|
|
||||||
(catch java.io.IOException _cause
|
(catch java.io.IOException _cause
|
||||||
;; Do nothing, EOF means client closes connection abruptly
|
;; Do nothing, EOF means client closes connection abruptly
|
||||||
(vreset! ab true)
|
(vreset! ab true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue