diff --git a/backend/src/app/binfile/common.clj b/backend/src/app/binfile/common.clj index d4d1bf3b7..a0b256660 100644 --- a/backend/src/app/binfile/common.clj +++ b/backend/src/app/binfile/common.clj @@ -409,8 +409,9 @@ [cfg data file-id] (let [library-ids (get-libraries cfg [file-id])] (reduce (fn [data library-id] - (let [library (get-file cfg library-id)] - (ctf/absorb-assets data (:data library)))) + (if-let [library (get-file cfg library-id)] + (ctf/absorb-assets data (:data library)) + data)) data library-ids))) diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index d60345169..006fc5ff0 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -530,7 +530,7 @@ (defn- match-storage-entry-fn [] - (let [pattern (str "^objects/([^/]+).json$") + (let [pattern "^objects/([^/]+).json$" pattern (re-pattern pattern)] (fn [entry] (when-let [[_ id] (re-matches pattern (zip-entry-name entry))] diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index aa82cb354..35e58bbca 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -55,13 +55,16 @@ ::yres/body (ex-data err)}) (defmethod handle-error :restriction - [err _ _] + [err request _] (let [{:keys [code] :as data} (ex-data err)] (if (= code :method-not-allowed) {::yres/status 405 ::yres/body data} - {::yres/status 400 - ::yres/body data}))) + + (binding [l/*context* (request->context request)] + (l/err :hint "restriction error" :data data) + {::yres/status 400 + ::yres/body data})))) (defmethod handle-error :rate-limit [err _ _] diff --git a/backend/src/app/loggers/database.clj b/backend/src/app/loggers/database.clj index 476180be0..41584eddc 100644 --- a/backend/src/app/loggers/database.clj +++ b/backend/src/app/loggers/database.clj @@ -59,7 +59,7 @@ :props (pp/pprint-str props :length 50) :hint (or (ex-message cause) @message) :trace (or (::trace record) - (ex/format-throwable cause :data? false :explain? false :header? false :summary? false))} + (some-> cause (ex/format-throwable :data? false :explain? false :header? false :summary? false)))} (when-let [params (or (:request/params context) (:params context))] {:params (pp/pprint-str params :length 30 :level 13)}) @@ -74,9 +74,8 @@ {:explain explain}))))) (defn error-record? - [{:keys [::l/level ::l/cause]}] - (and (= :error level) - (ex/exception? cause))) + [{:keys [::l/level]}] + (= :error level)) (defn- handle-event [{:keys [::db/pool]} {:keys [::l/id] :as record}] diff --git a/backend/src/app/srepl/fixes.clj b/backend/src/app/srepl/fixes.clj index fa76631ea..117030397 100644 --- a/backend/src/app/srepl/fixes.clj +++ b/backend/src/app/srepl/fixes.clj @@ -55,7 +55,7 @@ (let [conn (db/get-connection h/*system*) used (cfh/collect-used-media data) ids (db/create-array conn "uuid" used) - sql (str "SELECT * FROM file_media_object WHERE id = ANY(?)") + sql "SELECT * FROM file_media_object WHERE id = ANY(?)" rows (db/exec! conn [sql ids]) index (reduce (fn [index media] (if (not= (:file-id media) id) diff --git a/backend/src/app/srepl/fixes/media_refs.clj b/backend/src/app/srepl/fixes/media_refs.clj index 497dde358..44d3cc6e0 100644 --- a/backend/src/app/srepl/fixes/media_refs.clj +++ b/backend/src/app/srepl/fixes/media_refs.clj @@ -20,7 +20,7 @@ (mapcat (fn [object] (->> (cfh/collect-shape-media-refs object) (map (fn [id] - {:object-id (:id object) + {:shape-id (:id object) :id id})))))) process-page (fn [result page-id container] diff --git a/backend/src/app/srepl/helpers.clj b/backend/src/app/srepl/helpers.clj index 126a3db51..2ea26e3bb 100644 --- a/backend/src/app/srepl/helpers.clj +++ b/backend/src/app/srepl/helpers.clj @@ -39,10 +39,7 @@ ([id] (get-file (or *system* main/system) id)) ([system id] - (db/run! system - (fn [system] - (->> (bfc/get-file system id ::db/for-update true) - (bfc/decode-file system)))))) + (db/run! system bfc/get-file id))) (defn get-raw-file "Get the migrated data of one file." @@ -135,9 +132,10 @@ (bfc/get-file system id)))) (d/index-by :id))) - file' (if with-libraries? - (update-fn file libs opts) - (update-fn file opts))] + file' (when file + (if with-libraries? + (update-fn file libs opts) + (update-fn file opts)))] (when (and (some? file') (not (identical? file file'))) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 9e8d9cb7d..77b609698 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -673,7 +673,7 @@ (d/update-in-when data [:components component-id] update-container)))) (defn- process-operations - [objects {:keys [id operations] :as change}] + [objects {:keys [page-id id operations] :as change}] (if-let [shape (get objects id)] (let [shape (reduce process-operation shape operations) touched? (-> shape meta ::ctn/touched)] @@ -682,6 +682,10 @@ ;; need to report them for to be used in the second ;; phase of changes procesing (when touched? (some-> *touched-changes* (vswap! conj change))) + + (when (and *state* page-id) + (swap! *state* collect-shape-media-refs shape page-id)) + (assoc objects id shape)) objects))