|
|
@@ -1481,9 +1481,10 @@
|
|
|
true
|
|
|
r)))))))
|
|
|
|
|
|
+(declare sync-state-reset-full-remote->local-files)
|
|
|
(defn apply-filetxns-partitions
|
|
|
"won't call <update-graphs-txid! when *txid is nil"
|
|
|
- [*sync-state user-uuid graph-uuid base-path filetxns-partitions repo *txid *stopped *paused]
|
|
|
+ [*sync-state user-uuid graph-uuid base-path filetxns-partitions repo *txid *stopped *paused full-sync?]
|
|
|
(assert (some? *sync-state))
|
|
|
|
|
|
(go-loop [filetxns-partitions* filetxns-partitions]
|
|
|
@@ -1495,6 +1496,8 @@
|
|
|
(let [filetxns (first filetxns-partitions*)
|
|
|
paths (map relative-path filetxns)
|
|
|
recent-remote->local-file-items (filetxns=>recent-remote->local-files filetxns)
|
|
|
+ _ (when-not full-sync?
|
|
|
+ (swap! *sync-state #(sync-state-reset-full-remote->local-files % recent-remote->local-file-items)))
|
|
|
;; update recent-remote->local-files
|
|
|
_ (swap! *sync-state sync-state--add-recent-remote->local-files
|
|
|
recent-remote->local-file-items)
|
|
|
@@ -1952,6 +1955,7 @@
|
|
|
(def app-state-changed-cursor (rum/cursor state/state :mobile/app-state-change))
|
|
|
(add-watch app-state-changed-cursor "sync"
|
|
|
(fn [_ _ _ {:keys [is-active?]}]
|
|
|
+ (prn "is-active? " is-active?)
|
|
|
(offer! pause-resume-chan is-active?)))
|
|
|
|
|
|
(def recent-edited-chan
|
|
|
@@ -2147,13 +2151,15 @@
|
|
|
:epoch (tc/to-epoch (t/now))}})
|
|
|
(<! (apply-filetxns-partitions
|
|
|
*sync-state user-uuid graph-uuid base-path partitioned-filetxns repo
|
|
|
- nil *stopped *paused))))]
|
|
|
+ nil *stopped *paused true))))]
|
|
|
(cond
|
|
|
(instance? ExceptionInfo r) {:unknown r}
|
|
|
@*stopped {:stop true}
|
|
|
@*paused {:pause true}
|
|
|
:else
|
|
|
- (do (<! (<update-graphs-txid! latest-txid graph-uuid user-uuid repo))
|
|
|
+ (do
|
|
|
+ (swap! *sync-state #(sync-state-reset-full-remote->local-files % []))
|
|
|
+ (<! (<update-graphs-txid! latest-txid graph-uuid user-uuid repo))
|
|
|
(reset! *txid latest-txid)
|
|
|
{:succ true})))))
|
|
|
|
|
|
@@ -2175,18 +2181,21 @@
|
|
|
(completing (fn [r i] (conj r (reverse i)))) ;reverse
|
|
|
'()
|
|
|
(reverse diff-txns))]
|
|
|
+ ;; (swap! *sync-state #(sync-state-reset-full-remote->local-files % files))
|
|
|
(put-sync-event! {:event :start
|
|
|
:data {:type :remote->local
|
|
|
:graph-uuid graph-uuid
|
|
|
:full-sync? false
|
|
|
:epoch (tc/to-epoch (t/now))}})
|
|
|
(if (empty? (flatten partitioned-filetxns))
|
|
|
- (do (<! (<update-graphs-txid! latest-txid graph-uuid user-uuid repo))
|
|
|
- (reset! *txid latest-txid)
|
|
|
- {:succ true})
|
|
|
+ (do
|
|
|
+ (swap! *sync-state #(sync-state-reset-full-remote->local-files % []))
|
|
|
+ (<! (<update-graphs-txid! latest-txid graph-uuid user-uuid repo))
|
|
|
+ (reset! *txid latest-txid)
|
|
|
+ {:succ true})
|
|
|
(<! (apply-filetxns-partitions
|
|
|
*sync-state user-uuid graph-uuid base-path
|
|
|
- partitioned-filetxns repo *txid *stopped *paused)))))))))]
|
|
|
+ partitioned-filetxns repo *txid *stopped *paused false)))))))))]
|
|
|
(cond
|
|
|
(instance? ExceptionInfo r) {:unknown r}
|
|
|
@*stopped {:stop true}
|
|
|
@@ -2645,7 +2654,7 @@
|
|
|
(.schedule this next-state nil nil)))))
|
|
|
|
|
|
(pause [this]
|
|
|
- (<! (<rsapi-cancel-all-requests))
|
|
|
+ (go (<! (<rsapi-cancel-all-requests)))
|
|
|
(put-sync-event! {:event :pause
|
|
|
:data {:graph-uuid graph-uuid
|
|
|
:epoch (tc/to-epoch (t/now))}})
|
|
|
@@ -2702,11 +2711,13 @@
|
|
|
(s/assert ::sync-local->remote-all-files!-result r)
|
|
|
(cond
|
|
|
succ
|
|
|
- (do (put-sync-event! {:event :finished-local->remote
|
|
|
- :data {:graph-uuid graph-uuid
|
|
|
- :full-sync? true
|
|
|
- :epoch (tc/to-epoch (t/now))}})
|
|
|
- (.schedule this ::idle nil nil))
|
|
|
+ (do
|
|
|
+ (swap! *sync-state #(sync-state-reset-full-local->remote-files % []))
|
|
|
+ (put-sync-event! {:event :finished-local->remote
|
|
|
+ :data {:graph-uuid graph-uuid
|
|
|
+ :full-sync? true
|
|
|
+ :epoch (tc/to-epoch (t/now))}})
|
|
|
+ (.schedule this ::idle nil nil))
|
|
|
need-sync-remote
|
|
|
(do (util/drain-chan ops-chan)
|
|
|
(>! ops-chan {:remote->local true})
|
|
|
@@ -2810,12 +2821,14 @@
|
|
|
(or need-sync-remote graph-has-been-deleted unknown pause stop) r))))]
|
|
|
(cond
|
|
|
succ
|
|
|
- (do (put-sync-event! {:event :finished-local->remote
|
|
|
- :data {:graph-uuid graph-uuid
|
|
|
- :full-sync? false
|
|
|
- :file-change-events distincted-local-changes
|
|
|
- :epoch (tc/to-epoch (t/now))}})
|
|
|
- (.schedule this ::idle nil nil))
|
|
|
+ (do
|
|
|
+ (swap! *sync-state #(sync-state-reset-full-local->remote-files % []))
|
|
|
+ (put-sync-event! {:event :finished-local->remote
|
|
|
+ :data {:graph-uuid graph-uuid
|
|
|
+ :full-sync? false
|
|
|
+ :file-change-events distincted-local-changes
|
|
|
+ :epoch (tc/to-epoch (t/now))}})
|
|
|
+ (.schedule this ::idle nil nil))
|
|
|
|
|
|
need-sync-remote
|
|
|
(do (util/drain-chan ops-chan)
|
|
|
@@ -2874,7 +2887,9 @@
|
|
|
local->remote-syncer (->Local->RemoteSyncer user-uuid graph-uuid
|
|
|
base-path
|
|
|
repo *sync-state remoteapi-with-stop
|
|
|
- 20000
|
|
|
+ (if (mobile-util/native-platform?)
|
|
|
+ 2000
|
|
|
+ 20000)
|
|
|
*txid nil (chan) *stopped? *paused?
|
|
|
(chan 1) (chan 1))
|
|
|
remote->local-syncer (->Remote->LocalSyncer user-uuid graph-uuid base-path
|