0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-10 06:41:40 -05:00

🐛 Fix import files with unexpected format or invalid content

This commit is contained in:
Alejandro Alonso 2022-09-22 14:04:00 +02:00
parent f3115f8f3a
commit 5d01a0e24c
3 changed files with 17 additions and 6 deletions

View file

@ -17,6 +17,7 @@
- Fix change opacity in colorpicker cause bugged color [Taiga #4154](https://tree.taiga.io/project/penpot/issue/4154)
- Fix gradient colors don't arrive in recent colors palette (https://tree.taiga.io/project/penpot/issue/4155)
- Fix selected colors allow gradients in shadows [Taiga #4156](https://tree.taiga.io/project/penpot/issue/4156)
- Fix import files with unexpected format or invalid content [Taiga #4136](https://tree.taiga.io/project/penpot/issue/4136)
## 1.15.3-beta

View file

@ -304,7 +304,8 @@
success-files (->> @state :files (filter #(and (= (:status %) :import-finish) (empty? (:errors %)))) count)
pending-analysis? (> (->> @state :files (filter #(= (:status %) :analyzing)) count) 0)
pending-import? (> (->> @state :files (filter #(= (:status %) :importing)) count) 0)
files (->> (:files @state) (filterv (comp not :deleted?)))]
files (->> (:files @state) (filterv (comp not :deleted?)))
valid-files? (> (->> files (filterv (fn [x] (not= (:status x) :analyze-error))) count) 0)]
(mf/use-effect
(fn []
@ -359,7 +360,7 @@
{:class "primary"
:type "button"
:value (tr "labels.continue")
:disabled pending-analysis?
:disabled (or pending-analysis? (not valid-files?))
:on-click handle-continue}])
(when (= :importing (:status @state))
@ -367,5 +368,5 @@
{:class "primary"
:type "button"
:value (tr "labels.accept")
:disabled pending-import?
:disabled (or pending-import? (not valid-files?))
:on-click handle-accept}])]]]]))

View file

@ -19,6 +19,7 @@
[app.common.uuid :as uuid]
[app.main.repo :as rp]
[app.util.http :as http]
[app.util.i18n :as i18n :refer [tr]]
[app.util.import.parser :as cip]
[app.util.json :as json]
[app.util.webapi :as wapi]
@ -526,7 +527,8 @@
sg (areduce u8 i ret "" (str ret (if (zero? i) "" " ") (.toString (aget u8 i) 8)))]
(case sg
"120 113 3 4" "application/zip"
"application/octet-stream")))
"1 13 32 206" "application/octet-stream"
"other")))
(defmethod impl/handler :analyze-import
[{:keys [files]}]
@ -560,8 +562,15 @@
:file-id file-id
:files {file-id {:name (:name file)}}
:status :ready}
:type "application/octet-stream"})))))
(rx/catch #(rx/of {:uri (:uri file) :error (.-message %)}))))))))
:type "application/octet-stream"}))))
(->> st
(rx/filter (fn [data] (= "other" (:type data))))
(rx/map (fn [_]
{:uri (:uri file)
:error (tr "dashboard.import.analyze-error")}))))
(rx/catch (fn [data]
(let [error (or (.-message data) (tr "dashboard.import.analyze-error"))]
(rx/of {:uri (:uri file) :error error}))))))))))
(defmethod impl/handler :import-files
[{:keys [project-id files]}]