mirror of
https://github.com/penpot/penpot.git
synced 2025-05-25 01:26:10 +02:00
🐛 Fix file etag calculation considering the profile id too
This commit is contained in:
parent
2648dc3d27
commit
17731db28b
2 changed files with 15 additions and 7 deletions
|
@ -355,8 +355,8 @@
|
||||||
(db/get pool :file {:id id} {:columns [:id :modified-at :revn]}))
|
(db/get pool :file {:id id} {:columns [:id :modified-at :revn]}))
|
||||||
|
|
||||||
(defn get-file-etag
|
(defn get-file-etag
|
||||||
[{:keys [modified-at revn]}]
|
[{:keys [::rpc/profile-id]} {:keys [modified-at revn]}]
|
||||||
(str (dt/format-instant modified-at :iso) "-" revn))
|
(str profile-id (dt/format-instant modified-at :iso) revn))
|
||||||
|
|
||||||
(sv/defmethod ::get-file
|
(sv/defmethod ::get-file
|
||||||
"Retrieve a file by its ID. Only authenticated users."
|
"Retrieve a file by its ID. Only authenticated users."
|
||||||
|
@ -371,7 +371,7 @@
|
||||||
(check-read-permissions! perms)
|
(check-read-permissions! perms)
|
||||||
(let [file (-> (get-file conn id features project-id)
|
(let [file (-> (get-file conn id features project-id)
|
||||||
(assoc :permissions perms))]
|
(assoc :permissions perms))]
|
||||||
(vary-meta file assoc ::cond/key (get-file-etag file))))))
|
(vary-meta file assoc ::cond/key (get-file-etag params file))))))
|
||||||
|
|
||||||
|
|
||||||
;; --- COMMAND QUERY: get-file-fragment (by id)
|
;; --- COMMAND QUERY: get-file-fragment (by id)
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.rpc.helpers :as rph]
|
[app.rpc.helpers :as rph]
|
||||||
[app.util.services :as-alias sv]
|
[app.util.services :as-alias sv]
|
||||||
|
[buddy.core.codecs :as bc]
|
||||||
|
[buddy.core.hash :as bh]
|
||||||
[yetti.response :as yrs]))
|
[yetti.response :as yrs]))
|
||||||
|
|
||||||
(def
|
(def
|
||||||
|
@ -34,9 +36,16 @@
|
||||||
:doc "Runtime flag for enable/disable conditional processing of RPC methods."}
|
:doc "Runtime flag for enable/disable conditional processing of RPC methods."}
|
||||||
*enabled* false)
|
*enabled* false)
|
||||||
|
|
||||||
|
(defn- encode
|
||||||
|
[s]
|
||||||
|
(-> s
|
||||||
|
bh/blake2b-256
|
||||||
|
bc/bytes->b64u
|
||||||
|
bc/bytes->str))
|
||||||
|
|
||||||
(defn- fmt-key
|
(defn- fmt-key
|
||||||
[s]
|
[s]
|
||||||
(str "W/\"" s "\""))
|
(str "W/\"" (encode s) "\""))
|
||||||
|
|
||||||
(defn wrap
|
(defn wrap
|
||||||
[_ f {:keys [::get-object ::key-fn ::reuse-key?] :as mdata}]
|
[_ f {:keys [::get-object ::key-fn ::reuse-key?] :as mdata}]
|
||||||
|
@ -46,9 +55,8 @@
|
||||||
(fn [cfg {:keys [::key] :as params}]
|
(fn [cfg {:keys [::key] :as params}]
|
||||||
(if *enabled*
|
(if *enabled*
|
||||||
(let [key' (when (or key reuse-key?)
|
(let [key' (when (or key reuse-key?)
|
||||||
(some-> (get-object cfg params) key-fn fmt-key))]
|
(some->> (get-object cfg params) (key-fn params) (fmt-key)))]
|
||||||
(if (and (some? key)
|
(if (and (some? key) (= key key'))
|
||||||
(= key key'))
|
|
||||||
(fn [_] {::yrs/status 304})
|
(fn [_] {::yrs/status 304})
|
||||||
(let [result (f cfg params)
|
(let [result (f cfg params)
|
||||||
etag (or (and reuse-key? key')
|
etag (or (and reuse-key? key')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue