🐛 Fix some issues on read-only database connection

This commit is contained in:
Andrey Antukh 2023-03-31 12:36:54 +02:00 committed by Alonso Torres
parent 90d48c1d30
commit 0c89b7cdb1
2 changed files with 8 additions and 6 deletions

View file

@ -1007,13 +1007,13 @@
;; --- MUTATION COMMAND: upsert-file-thumbnail ;; --- MUTATION COMMAND: upsert-file-thumbnail
(def sql:upsert-file-thumbnail (def ^:private sql:upsert-file-thumbnail
"insert into file_thumbnail (file_id, revn, data, props) "insert into file_thumbnail (file_id, revn, data, props)
values (?, ?, ?, ?::jsonb) values (?, ?, ?, ?::jsonb)
on conflict(file_id, revn) do on conflict(file_id, revn) do
update set data = ?, props=?, updated_at=now();") update set data = ?, props=?, updated_at=now();")
(defn upsert-file-thumbnail (defn- upsert-file-thumbnail!
[conn {:keys [file-id revn data props]}] [conn {:keys [file-id revn data props]}]
(let [props (db/tjson (or props {}))] (let [props (db/tjson (or props {}))]
(db/exec-one! conn [sql:upsert-file-thumbnail (db/exec-one! conn [sql:upsert-file-thumbnail
@ -1033,5 +1033,6 @@
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}] [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}]
(db/with-atomic [conn pool] (db/with-atomic [conn pool]
(check-edition-permissions! conn profile-id file-id) (check-edition-permissions! conn profile-id file-id)
(upsert-file-thumbnail conn params) (when-not (db/read-only? conn)
(upsert-file-thumbnail! conn params))
nil)) nil))

View file

@ -153,9 +153,10 @@
(defn update-profile-password! (defn update-profile-password!
[conn {:keys [id password] :as profile}] [conn {:keys [id password] :as profile}]
(when-not (db/read-only? conn)
(db/update! conn :profile (db/update! conn :profile
{:password (auth/derive-password password)} {:password (auth/derive-password password)}
{:id id})) {:id id})))
;; --- MUTATION: Update Photo ;; --- MUTATION: Update Photo