0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

Merge branch 'hotfixes' into main

This commit is contained in:
Andrey Antukh 2021-02-10 12:30:04 +01:00
commit 1da43bb5b5
7 changed files with 26 additions and 19 deletions

View file

@ -52,7 +52,6 @@
:registration-domain-whitelist ""
:telemetry-enabled false
:telemetry-with-taiga true
:telemetry-uri "https://telemetry.penpot.app/"
;; LDAP auth disabled by default. Set ldap-auth-host to enable

View file

@ -72,7 +72,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def initsql
(str "SET statement_timeout = 10000;\n"
(str "SET statement_timeout = 60000;\n"
"SET idle_in_transaction_session_timeout = 120000;"))
(defn- create-datasource-config

View file

@ -192,19 +192,19 @@
:fn (ig/ref :app.tasks.file-media-gc/handler)}
{:id "file-xlog-gc"
:cron #app/cron "0 0 */6 * * ?" ;; every 2 hours
:cron #app/cron "0 0 */1 * * ?" ;; hourly
:fn (ig/ref :app.tasks.file-xlog-gc/handler)}
{:id "storage-deleted-gc"
:cron #app/cron "0 0 */6 * * ?" ;; every 6 hours
:cron #app/cron "0 0 1 */1 * ?" ;; daily (1 hour shift)
:fn (ig/ref :app.storage/gc-deleted-task)}
{:id "storage-touched-gc"
:cron #app/cron "0 30 */6 * * ?" ;; every 6 hours
:cron #app/cron "0 0 2 */1 * ?" ;; daily (2 hour shift)
:fn (ig/ref :app.storage/gc-touched-task)}
{:id "storage-recheck"
:cron #app/cron "0 0 */6 * * ?" ;; every 6 hours
:cron #app/cron "0 0 */1 * * ?" ;; hourly
:fn (ig/ref :app.storage/recheck-task)}
{:id "tasks-gc"
@ -260,7 +260,7 @@
:app.tasks.file-xlog-gc/handler
{:pool (ig/ref :app.db/pool)
:metrics (ig/ref :app.metrics/metrics)
:max-age (dt/duration {:hours 24})}
:max-age (dt/duration {:hours 48})}
:app.tasks.telemetry/handler
{:pool (ig/ref :app.db/pool)

View file

@ -38,7 +38,7 @@
;; --- Create File Media object (upload)
(declare create-file-media-object)
(declare select-file-for-update)
(declare select-file)
(s/def ::content ::media/upload)
(s/def ::is-local ::us/boolean)
@ -50,7 +50,7 @@
(sv/defmethod ::upload-file-media-object
[{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}]
(db/with-atomic [conn pool]
(let [file (select-file-for-update conn file-id)]
(let [file (select-file conn file-id)]
(teams/check-edition-permissions! conn profile-id (:team-id file))
(-> (assoc cfg :conn conn)
(create-file-media-object params)))))
@ -129,7 +129,7 @@
(sv/defmethod ::create-file-media-object-from-url
[{:keys [pool storage] :as cfg} {:keys [profile-id file-id url name] :as params}]
(db/with-atomic [conn pool]
(let [file (select-file-for-update conn file-id)]
(let [file (select-file conn file-id)]
(teams/check-edition-permissions! conn profile-id (:team-id file))
(let [mobj (download-media cfg url)
content {:filename "tempfile"
@ -152,7 +152,7 @@
(sv/defmethod ::clone-file-media-object
[{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}]
(db/with-atomic [conn pool]
(let [file (select-file-for-update conn file-id)]
(let [file (select-file conn file-id)]
(teams/check-edition-permissions! conn profile-id (:team-id file))
(-> (assoc cfg :conn conn)
@ -175,17 +175,17 @@
;; --- HELPERS
(def ^:private sql:select-file-for-update
(def ^:private
sql:select-file
"select file.*,
project.team_id as team_id
from file
inner join project on (project.id = file.project_id)
where file.id = ?
for update of file")
where file.id = ?")
(defn- select-file-for-update
(defn- select-file
[conn id]
(let [row (db/exec-one! conn [sql:select-file-for-update id])]
(let [row (db/exec-one! conn [sql:select-file id])]
(when-not row
(ex/raise :type :not-found))
row))

View file

@ -63,6 +63,7 @@
:uri (:uri cfg)
:headers {"content-type" "application/json"}
:body (json/encode-str data)})]
(when (not= 200 (:status response))
(ex/raise :type :internal
:code :invalid-response-from-google
@ -129,7 +130,7 @@
[{:keys [conn version]}]
(merge
{:version version
:with-taiga (:telemetry-with-taiga cfg/config)
:with-taiga (:telemetry-with-taiga cfg/config false)
:total-teams (retrieve-num-teams conn)
:total-projects (retrieve-num-projects conn)
:total-files (retrieve-num-files conn)}

View file

@ -12,6 +12,7 @@
[app.common.spec :as us]
[app.db :as db]
[app.http.middleware :refer [wrap-parse-request-body]]
[clojure.pprint :refer [pprint]]
[clojure.spec.alpha :as s]
[clojure.tools.logging :as log]
[integrant.core :as ig]
@ -87,7 +88,12 @@
(catch Exception e
;; We don't want notify user of a error, just log it for posible
;; future investigation.
(log/warnf e "Unexpected error on telemetry.")))
(log/warn e (str "Unexpected error on telemetry:\n"
(when-let [edata (ex-data e)]
(str "ex-data: \n"
(with-out-str (pprint edata))))
(str "params: \n"
(with-out-str (pprint params)))))))
{:status 200
:body "OK\n"})

View file

@ -137,7 +137,8 @@
(d/index-by :id)
(assoc state :comment-threads)))
(on-error [{:keys [type] :as err}]
(if (= :authentication type)
(if (or (= :authentication type)
(= :not-found type))
(rx/empty)
(rx/throw err)))]