|
|
@@ -1,4 +1,5 @@
|
|
|
(ns frontend.db.rtc.full-upload-download-graph
|
|
|
+ (:require-macros [frontend.db.rtc.macro :refer [with-sub-data-from-ws get-req-id get-result-ch]])
|
|
|
(:require [frontend.db.conn :as conn]
|
|
|
[datascript.core :as d]
|
|
|
[frontend.db.rtc.ws :refer [send]]
|
|
|
@@ -24,19 +25,22 @@
|
|
|
(defn- <upload-graph
|
|
|
[state]
|
|
|
(go
|
|
|
- (let [req-id (str (random-uuid))
|
|
|
- ch (chan 1)
|
|
|
- data-from-ws-pub (:data-from-ws-pub state)]
|
|
|
- (async/sub data-from-ws-pub req-id ch)
|
|
|
- (send (:ws state) {:req-id req-id :action "presign-put-temp-s3-obj" :graph-uuid "not-yet"})
|
|
|
- (let [all-blocks (export-as-blocks (state/get-current-repo))
|
|
|
- all-blocks-str (transit/write (transit/writer :json) all-blocks)
|
|
|
- {:keys [url key]} (<! ch)]
|
|
|
- (async/unsub data-from-ws-pub req-id ch)
|
|
|
- (<! (http/put url {:body all-blocks-str}))
|
|
|
- (let [req-id2 (str (random-uuid))
|
|
|
- ch2 (chan 1)]
|
|
|
- (async/sub data-from-ws-pub req-id2 ch2)
|
|
|
- (send (:ws state) {:req-id req-id2 :action "full-upload-graph" :graph-uuid "not-yet" :s3-key key})
|
|
|
- (println (<! ch2))
|
|
|
- (async/unsub data-from-ws-pub req-id2 ch2))))))
|
|
|
+ (let [{:keys [url key all-blocks-str]}
|
|
|
+ (with-sub-data-from-ws state
|
|
|
+ (send (:ws state) {:req-id (get-req-id) :action "presign-put-temp-s3-obj" :graph-uuid "not-yet"})
|
|
|
+ (let [all-blocks (export-as-blocks (state/get-current-repo))
|
|
|
+ all-blocks-str (transit/write (transit/writer :json) all-blocks)]
|
|
|
+ (merge (<! (get-result-ch)) {:all-blocks-str all-blocks-str})))]
|
|
|
+ (<! (http/put url {:body all-blocks-str}))
|
|
|
+ (with-sub-data-from-ws state
|
|
|
+ (send (:ws state) {:req-id (get-req-id) :action "full-upload-graph" :graph-uuid "not-yet" :s3-key key})
|
|
|
+ (println (<! (get-result-ch)))))))
|
|
|
+
|
|
|
+
|
|
|
+(defn- <download-graph
|
|
|
+ [state graph-uuid]
|
|
|
+ (go
|
|
|
+ (let [r (with-sub-data-from-ws state
|
|
|
+ (send (:ws state) {:req-id (get-req-id) :action "full-download-graph" :graph-uuid graph-uuid})
|
|
|
+ (<! (get-result-ch)))]
|
|
|
+ (prn r))))
|