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:
parent
f3115f8f3a
commit
5d01a0e24c
3 changed files with 17 additions and 6 deletions
|
@ -17,6 +17,7 @@
|
||||||
- Fix change opacity in colorpicker cause bugged color [Taiga #4154](https://tree.taiga.io/project/penpot/issue/4154)
|
- 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 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 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
|
## 1.15.3-beta
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,8 @@
|
||||||
success-files (->> @state :files (filter #(and (= (:status %) :import-finish) (empty? (:errors %)))) count)
|
success-files (->> @state :files (filter #(and (= (:status %) :import-finish) (empty? (:errors %)))) count)
|
||||||
pending-analysis? (> (->> @state :files (filter #(= (:status %) :analyzing)) count) 0)
|
pending-analysis? (> (->> @state :files (filter #(= (:status %) :analyzing)) count) 0)
|
||||||
pending-import? (> (->> @state :files (filter #(= (:status %) :importing)) 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
|
(mf/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -359,7 +360,7 @@
|
||||||
{:class "primary"
|
{:class "primary"
|
||||||
:type "button"
|
:type "button"
|
||||||
:value (tr "labels.continue")
|
:value (tr "labels.continue")
|
||||||
:disabled pending-analysis?
|
:disabled (or pending-analysis? (not valid-files?))
|
||||||
:on-click handle-continue}])
|
:on-click handle-continue}])
|
||||||
|
|
||||||
(when (= :importing (:status @state))
|
(when (= :importing (:status @state))
|
||||||
|
@ -367,5 +368,5 @@
|
||||||
{:class "primary"
|
{:class "primary"
|
||||||
:type "button"
|
:type "button"
|
||||||
:value (tr "labels.accept")
|
:value (tr "labels.accept")
|
||||||
:disabled pending-import?
|
:disabled (or pending-import? (not valid-files?))
|
||||||
:on-click handle-accept}])]]]]))
|
:on-click handle-accept}])]]]]))
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.import.parser :as cip]
|
[app.util.import.parser :as cip]
|
||||||
[app.util.json :as json]
|
[app.util.json :as json]
|
||||||
[app.util.webapi :as wapi]
|
[app.util.webapi :as wapi]
|
||||||
|
@ -526,7 +527,8 @@
|
||||||
sg (areduce u8 i ret "" (str ret (if (zero? i) "" " ") (.toString (aget u8 i) 8)))]
|
sg (areduce u8 i ret "" (str ret (if (zero? i) "" " ") (.toString (aget u8 i) 8)))]
|
||||||
(case sg
|
(case sg
|
||||||
"120 113 3 4" "application/zip"
|
"120 113 3 4" "application/zip"
|
||||||
"application/octet-stream")))
|
"1 13 32 206" "application/octet-stream"
|
||||||
|
"other")))
|
||||||
|
|
||||||
(defmethod impl/handler :analyze-import
|
(defmethod impl/handler :analyze-import
|
||||||
[{:keys [files]}]
|
[{:keys [files]}]
|
||||||
|
@ -560,8 +562,15 @@
|
||||||
:file-id file-id
|
:file-id file-id
|
||||||
:files {file-id {:name (:name file)}}
|
:files {file-id {:name (:name file)}}
|
||||||
:status :ready}
|
:status :ready}
|
||||||
:type "application/octet-stream"})))))
|
:type "application/octet-stream"}))))
|
||||||
(rx/catch #(rx/of {:uri (:uri file) :error (.-message %)}))))))))
|
(->> 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
|
(defmethod impl/handler :import-files
|
||||||
[{:keys [project-id files]}]
|
[{:keys [project-id files]}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue