From 5126c85623073a1a07f9fa2a4adb42a89aab8cdc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Jul 2021 11:57:15 +0200 Subject: [PATCH] :bug: Properly handle path with fill-image on file media gc task. --- backend/src/app/tasks/file_media_gc.clj | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/src/app/tasks/file_media_gc.clj b/backend/src/app/tasks/file_media_gc.clj index bc1675447..aedcbc78b 100644 --- a/backend/src/app/tasks/file_media_gc.clj +++ b/backend/src/app/tasks/file_media_gc.clj @@ -64,16 +64,21 @@ (comp (map :objects) (mapcat vals) - (filter #(= :image (:type %))) - (map :metadata) - (map :id))) + (map (fn [{:keys [type] :as obj}] + (case type + :path (get-in obj [:fill-image :id]) + :image (get-in obj [:metadata :id]) + nil))) + (filter uuid?))) (defn- collect-used-media [data] + (let [pages (concat + (vals (:pages-index data)) + (vals (:components data)))] (-> #{} - (into collect-media-xf (vals (:pages-index data))) - (into collect-media-xf (vals (:components data))) - (into (keys (:media data))))) + (into collect-media-xf pages) + (into (keys (:media data)))))) (defn- process-file [{:keys [conn] :as cfg} {:keys [id data age] :as file}]