💄 Add cosmetic changes to get-file rpc method

This commit is contained in:
Andrey Antukh 2024-10-16 17:37:53 +02:00
parent 40d7bb04b4
commit 790f6ce4ed

View file

@ -292,9 +292,9 @@
::cond/get-object #(get-minimal-file-with-perms %1 %2) ::cond/get-object #(get-minimal-file-with-perms %1 %2)
::cond/key-fn get-file-etag ::cond/key-fn get-file-etag
::sm/params schema:get-file ::sm/params schema:get-file
::sm/result schema:file-with-permissions} ::sm/result schema:file-with-permissions
[cfg {:keys [::rpc/profile-id id project-id] :as params}] ::db/transaction true}
(db/tx-run! cfg (fn [{:keys [::db/conn] :as cfg}] [{:keys [::db/conn] :as cfg} {:keys [::rpc/profile-id id project-id] :as params}]
;; The COND middleware makes initial request for a file and ;; The COND middleware makes initial request for a file and
;; permissions when the incoming request comes with an ;; permissions when the incoming request comes with an
;; ETAG. When ETAG does not matches, the request is resolved ;; ETAG. When ETAG does not matches, the request is resolved
@ -312,21 +312,20 @@
file (-> (get-file cfg id :project-id project-id) file (-> (get-file cfg id :project-id project-id)
(assoc :permissions perms) (assoc :permissions perms)
(check-version!)) (check-version!))]
_ (-> (cfeat/get-team-enabled-features cf/flags team) (-> (cfeat/get-team-enabled-features cf/flags team)
(cfeat/check-client-features! (:features params)) (cfeat/check-client-features! (:features params))
(cfeat/check-file-features! (:features file) (:features params))) (cfeat/check-file-features! (:features file) (:features params)))
;; This operation is needed for backward comapatibility with frontends that ;; This operation is needed for backward comapatibility with frontends that
;; does not support pointer-map resolution mechanism; this just resolves the ;; does not support pointer-map resolution mechanism; this just resolves the
;; pointers on backend and return a complete file. ;; pointers on backend and return a complete file.
file (if (and (contains? (:features file) "fdata/pointer-map") (if (and (contains? (:features file) "fdata/pointer-map")
(not (contains? (:features params) "fdata/pointer-map"))) (not (contains? (:features params) "fdata/pointer-map")))
(binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg id)] (binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg id)]
(update file :data feat.fdata/process-pointers deref)) (update file :data feat.fdata/process-pointers deref))
file)] file))))
file)))))
;; --- COMMAND QUERY: get-file-fragment (by id) ;; --- COMMAND QUERY: get-file-fragment (by id)