diff --git a/backend/src/app/binfile/cleaner.clj b/backend/src/app/binfile/cleaner.clj index 1f27e7751b..74c394e2fe 100644 --- a/backend/src/app/binfile/cleaner.clj +++ b/backend/src/app/binfile/cleaner.clj @@ -90,13 +90,18 @@ (fix-root-shape) (fix-legacy-flex-dir))) +(defn- fix-container + [container] + (-> container + ;; Remove possible `nil` keys on objects + (d/update-when :objects dissoc nil) + (d/update-when :objects d/update-vals clean-shape-post-decode))) + (defn clean-file [file & {:as _opts}] - (let [update-container - (fn [container] - (d/update-when container :objects d/update-vals clean-shape-post-decode))] - (update file :data - (fn [data] - (-> data - (update :pages-index d/update-vals update-container) - (update :components d/update-vals update-container)))))) + (update file :data + (fn [data] + (-> data + (d/update-when :pages-index d/update-vals fix-container) + (d/update-when :components d/update-vals fix-container) + (d/without-nils))))) diff --git a/backend/src/app/tasks/file_gc.clj b/backend/src/app/tasks/file_gc.clj index daa3d60038..e2358061d7 100644 --- a/backend/src/app/tasks/file_gc.clj +++ b/backend/src/app/tasks/file_gc.clj @@ -10,6 +10,7 @@ file is eligible to be garbage collected after some period of inactivity (the default threshold is 72h)." (:require + [app.binfile.cleaner :as bfl] [app.binfile.common :as bfc] [app.common.files.helpers :as cfh] [app.common.files.validate :as cfv] @@ -258,6 +259,7 @@ (if-let [file (get-file cfg file-id)] (let [file (->> file (bfc/decode-file cfg) + (bfl/clean-file) (clean-media! cfg) (clean-fragments! cfg)) file (assoc file :has-media-trimmed true)]