From d241f4525311e2e4050a95051ba3b535a00e487b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 23 May 2024 15:20:48 +0200 Subject: [PATCH] :fire: Remove unnecessary async touch operation --- .../src/app/rpc/commands/files_thumbnails.clj | 2 +- backend/src/app/storage.clj | 25 +++++-------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/backend/src/app/rpc/commands/files_thumbnails.clj b/backend/src/app/rpc/commands/files_thumbnails.clj index bd982ce17..d766acd3c 100644 --- a/backend/src/app/rpc/commands/files_thumbnails.clj +++ b/backend/src/app/rpc/commands/files_thumbnails.clj @@ -271,7 +271,7 @@ (when (and (some? th1) (not= (:media-id th1) (:media-id th2))) - (sto/touch-object! storage (:media-id th1) :async true)) + (sto/touch-object! storage (:media-id th1))) th2)) diff --git a/backend/src/app/storage.clj b/backend/src/app/storage.clj index 070c53f3f..c818b03fa 100644 --- a/backend/src/app/storage.clj +++ b/backend/src/app/storage.clj @@ -16,7 +16,6 @@ [app.storage.impl :as impl] [app.storage.s3 :as ss3] [app.util.time :as dt] - [app.worker :as wrk] [clojure.spec.alpha :as s] [datoteka.fs :as fs] [integrant.core :as ig] @@ -171,28 +170,16 @@ (impl/put-object object content)) object))) -(def ^:private default-touch-delay - "A default delay for the asynchronous touch operation" - (dt/duration "5m")) - (defn touch-object! "Mark object as touched." - [{:keys [::db/pool-or-conn] :as storage} object-or-id & {:keys [async]}] + [{:keys [::db/pool-or-conn] :as storage} object-or-id] (us/assert! ::storage storage) (let [id (if (impl/object? object-or-id) (:id object-or-id) object-or-id)] - (if async - (wrk/submit! ::wrk/conn pool-or-conn - ::wrk/task :object-update - ::wrk/delay default-touch-delay - :object :storage-object - :id id - :key :touched-at - :val (dt/now)) - (-> (db/update! pool-or-conn :storage-object - {:touched-at (dt/now)} - {:id id}) - (db/get-update-count) - (pos?))))) + (-> (db/update! pool-or-conn :storage-object + {:touched-at (dt/now)} + {:id id}) + (db/get-update-count) + (pos?)))) (defn get-object-data "Return an input stream instance of the object content."