From aaa8bfe67d0a21993dbc01296d36df3fee3b5383 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 27 Jan 2020 16:38:43 +0100 Subject: [PATCH] :bug: Process thumbnail creation in serie (less resource usage). --- backend/src/uxbox/images.clj | 6 +++--- backend/src/uxbox/services/queries/images.clj | 4 ++-- backend/vendor/vertx/src/vertx/core.clj | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/src/uxbox/images.clj b/backend/src/uxbox/images.clj index 540ab8a44..fedb70e50 100644 --- a/backend/src/uxbox/images.clj +++ b/backend/src/uxbox/images.clj @@ -79,7 +79,7 @@ (defn populate-thumbnail [entry {:keys [src dst] :as opts}] - {:pre [(map? entry)]} + (assert (map? entry)) (let [src (if (vector? src) src [src]) dst (if (vector? dst) dst [dst]) src (get-in entry src)] @@ -93,8 +93,8 @@ (defn populate-urls [entry storage src dst] - {:pre [(map? entry) - (st/storage? storage)]} + (assert (map? entry)) + (assert (st/storage? storage)) (let [src (if (vector? src) src [src]) dst (if (vector? dst) dst [dst]) value (get-in entry src)] diff --git a/backend/src/uxbox/services/queries/images.clj b/backend/src/uxbox/services/queries/images.clj index ad1b04a5b..5b337b3ae 100644 --- a/backend/src/uxbox/services/queries/images.clj +++ b/backend/src/uxbox/services/queries/images.clj @@ -32,8 +32,8 @@ (defn populate-thumbnail [row] (let [opts +thumbnail-options+] - (-> (px/submit! #(images/populate-thumbnails row opts)) - (su/handle-on-context)))) + (-> (p/promise row) + (p/then (vc/wrap-blocking #(images/populate-thumbnail % opts)))))) (defn populate-thumbnails [rows] diff --git a/backend/vendor/vertx/src/vertx/core.clj b/backend/vendor/vertx/src/vertx/core.clj index 029adef99..2ce253c1a 100644 --- a/backend/vendor/vertx/src/vertx/core.clj +++ b/backend/vendor/vertx/src/vertx/core.clj @@ -71,12 +71,13 @@ (.complete ^Promise prm (apply f args)) (catch Throwable e (.fail ^Promise prm e))))) - false + true (reify Handler (handle [_ ar] (if (.failed ^AsyncResult ar) (p/reject! d (.cause ^AsyncResult ar)) - (p/resolve! d (.result ^AsyncResult ar))))))))))) + (p/resolve! d (.result ^AsyncResult ar)))))) + d))))) (defn handle-on-context "Attaches the context (current if not explicitly provided) to the