diff --git a/backend/src/app/binfile/common.clj b/backend/src/app/binfile/common.clj index 8cd4f8cd3..f461ab7b6 100644 --- a/backend/src/app/binfile/common.clj +++ b/backend/src/app/binfile/common.clj @@ -541,7 +541,6 @@ file) - (defn apply-pending-migrations! "Apply alredy registered pending migrations to files" [cfg] diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 358e23ea5..49ab84193 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -10,8 +10,10 @@ [app.binfile.common :as bfc] [app.binfile.v1 :as bf.v1] [app.binfile.v3 :as bf.v3] + [app.common.features :as cfeat] [app.common.logging :as l] [app.common.schema :as sm] + [app.config :as cf] [app.db :as db] [app.http.sse :as sse] [app.loggers.audit :as-alias audit] @@ -20,6 +22,7 @@ [app.rpc :as-alias rpc] [app.rpc.commands.files :as files] [app.rpc.commands.projects :as projects] + [app.rpc.commands.teams :as teams] [app.rpc.doc :as-alias doc] [app.tasks.file-gc] [app.util.services :as sv] @@ -91,41 +94,30 @@ ;; --- Command: import-binfile -(defn- import-binfile-v1 - [{:keys [::wrk/executor] :as cfg} {:keys [project-id profile-id name file]}] - (let [cfg (-> cfg - (assoc ::bfc/project-id project-id) - (assoc ::bfc/profile-id profile-id) - (assoc ::bfc/name name) - (assoc ::bfc/input (:path file)))] - - ;; NOTE: the importation process performs some operations that are - ;; not very friendly with virtual threads, and for avoid - ;; unexpected blocking of other concurrent operations we dispatch - ;; that operation to a dedicated executor. - (px/invoke! executor (partial bf.v1/import-files! cfg)))) - -(defn- import-binfile-v3 - [{:keys [::wrk/executor] :as cfg} {:keys [project-id profile-id name file]}] - (let [cfg (-> cfg - (assoc ::bfc/project-id project-id) - (assoc ::bfc/profile-id profile-id) - (assoc ::bfc/name name) - (assoc ::bfc/input (:path file)))] - ;; NOTE: the importation process performs some operations that are - ;; not very friendly with virtual threads, and for avoid - ;; unexpected blocking of other concurrent operations we dispatch - ;; that operation to a dedicated executor. - (px/invoke! executor (partial bf.v3/import-files! cfg)))) - (defn- import-binfile - [{:keys [::db/pool] :as cfg} {:keys [project-id version] :as params}] - (let [result (case (int version) - 1 (import-binfile-v1 cfg params) - 3 (import-binfile-v3 cfg params))] + [{:keys [::db/pool ::wrk/executor] :as cfg} {:keys [profile-id project-id version name file]}] + (let [team (teams/get-team pool + :profile-id profile-id + :project-id project-id) + cfg (-> cfg + (assoc ::bfc/features (cfeat/get-team-enabled-features cf/flags team)) + (assoc ::bfc/project-id project-id) + (assoc ::bfc/profile-id profile-id) + (assoc ::bfc/name name) + (assoc ::bfc/input (:path file))) + + ;; NOTE: the importation process performs some operations that are + ;; not very friendly with virtual threads, and for avoid + ;; unexpected blocking of other concurrent operations we dispatch + ;; that operation to a dedicated executor. + result (case (int version) + 1 (px/invoke! executor (partial bf.v1/import-files! cfg)) + 3 (px/invoke! executor (partial bf.v3/import-files! cfg)))] + (db/update! pool :project {:modified-at (dt/now)} {:id project-id}) + result)) (def ^:private schema:import-binfile