                       local-config
                       local-domain-root
                       remote-path
-                      (domain/host-shards (domains-info domain))
+                      host-shards
                       state)
          ;; use cached domain from local-dir (no update needed)
          (do

        domains (keys domains-info)]
    (log-message "Domains info: " domains-info)
    (future
      (try (purge-unused-domains! (set domains) local-dir)
           (sync-remote-data domains-info global-config local-config rw-lock)
           (cleanup-domains! domains local-dir)
           (log-message "Finished loading all updated domains from remote")

             :no-update
             (open-domain local-config
                          (str (path local-dir domain))
                          host-shards)))))))

(defn purge-unused-domains!
  "Walks through the supplied local directory, recursively deleting
  all directories with names that aren't present in the supplied
  `domains`."
  [domain-seq local-dir]
  (let [lfs (local-filesystem)
        domain-set (set domain-seq)]
    (dofor [domain-path (-> local-dir mk-local-path .listFiles)
            :when (and (.isDirectory domain-path)
                       (not (contains? domain-set
                                       (.getName domain-path))))]
           (log-message "Deleting local path of deleted domain: " domain-path)
           (delete lfs (.getPath domain-path) true))))

