From b8dee1707546c858c129287a442472821d296936 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 21 Aug 2023 17:29:01 +0200 Subject: [PATCH 1/8] :bug: Fix incorrect streams handling on thumbnail_render --- frontend/src/app/thumbnail_renderer.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/thumbnail_renderer.cljs b/frontend/src/app/thumbnail_renderer.cljs index d48780edf..f60b3d3ec 100644 --- a/frontend/src/app/thumbnail_renderer.cljs +++ b/frontend/src/app/thumbnail_renderer.cljs @@ -97,11 +97,12 @@ (defn- svg-update-image! "Updates an image in an SVG to a Data URI." [image] - (when-let [href (dom/get-attribute image "href")] + (if-let [href (dom/get-attribute image "href")] (->> (fetch-as-data-uri href) (rx/map (fn [url] (dom/set-attribute! image "href" url) - image))))) + image))) + (rx/empty))) (defn- svg-resolve-images! "Resolves all images in an SVG to Data URIs." From 661a916a5f53dc61140add681c94c82f4a39686d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 21 Aug 2023 18:03:49 +0200 Subject: [PATCH 2/8] :bug: Fix reference counting of file-media objects in :fill-image attr --- backend/src/app/rpc/commands/binfile.clj | 10 ++++++---- backend/src/app/tasks/file_gc.clj | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 72cb419c9..632239f2b 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -516,6 +516,9 @@ :media (count media) ::l/sync? true) + (doseq [item media] + (l/debug :hint "write penpot file media object" :id (:id item) ::l/sync? true)) + (doto output (write-obj! file) (write-obj! media)) @@ -770,7 +773,7 @@ (defn- lookup-index [id] (let [val (get-in @*state* [:index id])] - (l/trace :fn "lookup-index" :id id :val val ::l/sync? true) + (l/debug :fn "lookup-index" :id id :val val ::l/sync? true) (when (and (not (::ignore-index-errors? *options*)) (not val)) (ex/raise :type :validation :code :incomplete-index @@ -783,7 +786,7 @@ index index] (if-let [id (first items)] (let [new-id (if (::overwrite? *options*) id (uuid/next))] - (l/trace :fn "update-index" :id id :new-id new-id ::l/sync? true) + (l/debug :fn "update-index" :id id :new-id new-id ::l/sync? true) (recur (rest items) (assoc index id new-id))) index))) @@ -801,8 +804,7 @@ (update-in [:metadata :id] lookup-index) ;; Relink paths with fill image - (and (map? (:fill-image form)) - (= :path (:type form))) + (map? (:fill-image form)) (update-in [:fill-image :id] lookup-index) ;; This covers old shapes and the new :fills. diff --git a/backend/src/app/tasks/file_gc.clj b/backend/src/app/tasks/file_gc.clj index 9b9c2134a..ac83404a1 100644 --- a/backend/src/app/tasks/file_gc.clj +++ b/backend/src/app/tasks/file_gc.clj @@ -113,8 +113,15 @@ (mapcat vals) (keep (fn [{:keys [type] :as obj}] (case type - :path (get-in obj [:fill-image :id]) + :path (get-in obj [:fill-image :id]) + :bool (get-in obj [:fill-image :id]) + ;; NOTE: because of some bug, we ended with + ;; many shape types having the ability to + ;; have fill-image attribute (which initially + ;; designed for :path shapes). + :group (get-in obj [:fill-image :id]) :image (get-in obj [:metadata :id]) + nil)))) pages (concat (vals (:pages-index data)) From 834c18323ec22e264c20b2c18a840fdd7ff976ae Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 23 Aug 2023 09:38:07 +0200 Subject: [PATCH 3/8] Revert ":paperclip: Update version.txt file" This reverts commit a7f39e89f632595128ddf2361a1b8aa99b719f9b. --- backend/src/app/rpc/commands/files.clj | 15 ------------ frontend/src/app/main.cljs | 2 +- frontend/src/app/main/data/users.cljs | 23 ------------------- .../app/main/ui/settings/access_tokens.cljs | 13 ++++------- version.txt | 2 +- 5 files changed, 6 insertions(+), 49 deletions(-) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 66b76aa62..83cbfed23 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -375,21 +375,6 @@ [{:keys [::rpc/profile-id]} {:keys [modified-at revn]}] (str profile-id (dt/format-instant modified-at :iso) revn)) - - -(sv/defmethod ::hey - {::doc/added "1.17" - ::rpc/auth false} - [_ _] - (str (rand-int 100))) - -(sv/defmethod ::ho - {::doc/added "1.17" - ::rpc/auth false} - [_ _] - (str (rand-int 1000))) - - (sv/defmethod ::get-file "Retrieve a file by its ID. Only authenticated users." {::doc/added "1.17" diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index 65321cabb..50690807d 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -37,7 +37,7 @@ (log/setup! {:app :info}) (when (= :browser cf/target) - (log/info :message "Hey!,Welcome to penpot" + (log/info :message "Welcome to penpot" :version (:full cf/version) :asserts *assert* :build-date cf/build-date diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 82ad2a730..06ff50642 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -518,29 +518,6 @@ (->> (rp/cmd! :get-access-tokens) (rx/map access-tokens-fetched))))) - - - - -(defn heyhey-fetched - [value] - (ptk/reify ::heyhey-fetched - ptk/UpdateEvent - (update [_ state] - (assoc state :hey-value value)))) - - - -(defn fetch-heyhey - [] - (ptk/reify ::fetch-heyhey - ptk/WatchEvent - (watch [_ _ _] - (->> (rp/cmd! :hey) - (rx/map heyhey-fetched))))) - - - ;; --- EVENT: create-access-token (defn access-token-created diff --git a/frontend/src/app/main/ui/settings/access_tokens.cljs b/frontend/src/app/main/ui/settings/access_tokens.cljs index 6c9b329b6..2444324ed 100644 --- a/frontend/src/app/main/ui/settings/access_tokens.cljs +++ b/frontend/src/app/main/ui/settings/access_tokens.cljs @@ -260,21 +260,16 @@ [:& access-token-actions {:on-delete on-delete}]]])) -(def hey-ref - (l/derived :hey-value st/state)) - (mf/defc access-tokens-page [] (mf/with-effect [] (dom/set-html-title (tr "title.settings.access-tokens")) - (st/emit! (du/fetch-access-tokens)) - (st/emit! (du/fetch-heyhey))) + (st/emit! (du/fetch-access-tokens))) - (let [tokens (mf/deref tokens-ref) - hey (mf/deref hey-ref)] - [:div.dashboard-access-tokens {:style {:background "pink"}} + (let [tokens (mf/deref tokens-ref)] + [:div.dashboard-access-tokens [:div - [:div {:on-click #(st/emit! (du/fetch-heyhey))} hey] + [:& access-tokens-hero] (if (empty? tokens) [:div.access-tokens-empty [:div (tr "dashboard.access-tokens.empty.no-access-tokens")] diff --git a/version.txt b/version.txt index 66e2ae6c2..815d5ca06 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.19.1 +1.19.0 From 1f31722571848c500c7825ace839866996cc4cc3 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 23 Aug 2023 09:38:23 +0200 Subject: [PATCH 4/8] :paperclip: Update version.txt file --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 815d5ca06..66e2ae6c2 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.19.0 +1.19.1 From f02b5765d732ff01a187f4d921d5321e80a184f7 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 23 Aug 2023 14:59:08 +0200 Subject: [PATCH 5/8] :bug: Fix safe number max values --- common/src/app/common/schema.cljc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index 19e3046f8..494b1df2a 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -382,8 +382,10 @@ keyword identity)}}))}) -(def max-safe-int (int 1e6)) -(def min-safe-int (int -1e6)) +;; Integer/MAX_VALUE +(def max-safe-int 2147483647) +;; Integer/MIN_VALUE +(def min-safe-int -2147483648) (def! ::safe-int {:type ::safe-int From 5275c350023ffd6da7303aae22a41a050b87dfa1 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 24 Aug 2023 11:18:56 +0200 Subject: [PATCH 6/8] :bug: Prevent rollback for idle-in-transaction errors on cron tasks --- backend/src/app/worker.clj | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/src/app/worker.clj b/backend/src/app/worker.clj index 05c27f7f8..1c7bcfd1b 100644 --- a/backend/src/app/worker.clj +++ b/backend/src/app/worker.clj @@ -574,8 +574,11 @@ (l/trace :hint "register cron task" :id id :cron (str cron)) (db/exec-one! conn [sql:upsert-cron-task id (str cron) (str cron)])))) -(def sql:lock-cron-task - "select id from scheduled_task where id=? for update skip locked") +(defn- lock-scheduled-task! + [conn id] + (let [sql (str "SELECT id FROM scheduled_task " + " WHERE id=? FOR UPDATE SKIP LOCKED")] + (some? (db/exec-one! conn [sql (d/name id)])))) (defn- execute-cron-task [{:keys [::db/pool] :as cfg} {:keys [id] :as task}] @@ -583,11 +586,16 @@ {:name (str "penpot/cront-task/" id)} (try (db/with-atomic [conn pool] - (when (db/exec-one! conn [sql:lock-cron-task (d/name id)]) + (db/exec-one! conn ["SET statement_timeout=0;"]) + (db/exec-one! conn ["SET idle_in_transaction_session_timeout=0;"]) + (when (lock-scheduled-task! conn id) (l/trace :hint "cron: execute task" :task-id id) - ((:fn task) task))) + ((:fn task) task)) + (db/rollback! conn)) + (catch InterruptedException _ (l/debug :hint "cron: task interrupted" :task-id id)) + (catch Throwable cause (binding [l/*context* (get-error-context cause task)] (l/error :hint "cron: unhandled exception on running task" From d80aa7593b0e795f1dc51cc854d283779f1bc831 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 24 Aug 2023 11:37:59 +0200 Subject: [PATCH 7/8] :bug: Fix unexpected exception on encoding error response --- backend/src/app/http/errors.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index 6ca7d7f68..4b22cb493 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -81,7 +81,7 @@ (let [explain (ex/explain data)] {::yrs/status 400 ::yrs/body (-> data - (dissoc ::s/problems ::s/value) + (dissoc ::s/problems ::s/value ::s/spec) (cond-> explain (assoc :explain explain)))}) (= code :params-validation) From aaf9c6e50bccfe6e9fe32cfaab894b4f69628e4e Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 24 Aug 2023 12:00:56 +0200 Subject: [PATCH 8/8] :sparkles: Enable access tokens by default --- backend/scripts/start-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/scripts/start-dev b/backend/scripts/start-dev index a7f0045d1..d9ba4b1ce 100755 --- a/backend/scripts/start-dev +++ b/backend/scripts/start-dev @@ -15,7 +15,7 @@ export PENPOT_FLAGS="\ enable-fdata-storage-objets-map \ disable-secure-session-cookies \ enable-smtp \ - enable-webhooks"; + enable-access-tokens"; set -ex