 
 (defn sync-updated!
   [global-config local-config rw-lock]
-  (let [{:keys [hdfs-conf local-dir]} local-config
+  (let [{remote-path-map :domains} global-config
+        {:keys [hdfs-conf local-dir]} local-config
         domains-info (-> (filesystem hdfs-conf)
                          (init-domain-info-map global-config))
         domains (keys domains-info)]
     (log-message "Domains info: " domains-info)
     (future
       (try (purge-unused-domains! domains local-dir)
-           (sync-remote-data domains-info global-config local-config rw-lock)
+           (load-and-sync-status! domains-info remote-path-map local-config rw-lock)
            (cleanup-domains! domains local-dir)
            (log-message "Finished loading all updated domains from remote")
            (catch Throwable t

          (open-domain local-db-conf
                       local-domain-root
                       host-shards))))))
;; TODO: update state
(defnk load-and-sync-status
  [domains-info global-config local-config rw-lock
   :update? false
   :state nil]
  (let [status (if update?
                 (thrift/ready-status :loading? true)
                 (thrift/loading-status))
        loader-fn (fn [domain]
                    (let [host-shards (domain/host-shards (domains-info domain))
                          remote-path (-> global-config :domains (get domain))
                          state (or state (mk-loader-state {domain host-shards}))]
                      (use-cache-or-update domain
                                           host-shards
                                           remote-path
                                           local-config
                                           update?
                                           state)))
        loaders (dofor [[domain info] domains-info]
                       (domain/set-domain-status! info status)
                       (load-and-sync-domain-status domain
                                                    info
                                                    loader-fn
                                                    rw-lock))]
    (with-ret (future-values loaders)
      (log-message "Successfully loaded domains: "
                   (s/join ", " (keys domains-info))))))

    (reset! download-supervisor (start-download-supervisor shard-amount max-kbs state))
    (future
      ;; TODO: Curry this!
      (try (load-and-sync-status! domains-info
                                  (:domains global-config)
                                  local-config
                                  rw-lock
                                  :update? true
                                  :state state)
           (log-message "Finished updating all domains from remote.")
           (log-message "Removing all old versions of updated domains!")
           (try (cleanup-domains! (keys domains-info) local-dir)
