         (if firstErr
           [firstErr nil]
           (let [[onlyremote onlylocal both] (partition-files s3keys files)
-                deleteTask (delete-files s3 onlyremote delete whatif verbose)
-                copyTask (copy-files s3 onlylocal whatif)
-                updateTask (update-files-if-changed s3 both whatif force verbose)
-                [deleteErr _] (<! deleteTask)
-                [copyErr _] (<! copyTask)
-                [updateErr _] (<! updateTask)
-                firstErr (or deleteErr copyErr updateErr)]
-            (if firstErr
-              [firstErr nil]
-              [nil true])))))))+                actions (->>
+                          (concat
+                            (map #(make-copy-file-action s3 % whatif verbose) onlylocal)
+                            (->> onlyremote
+                                 (map (fn [key _] key))
+                                 (partition-all 1000)
+                                 (map #(make-delete-file-action s3 % delete whatif verbose)))
+                            (map #(make-update-file-action s3 % force whatif verbose) both))
+                          (vec))]
+            (<! (perform-actions 8 actions))))))))
                  :default {:bucket "kingjames-beta"
                            :region "us-east-1"
                            :profile "default"}}}
  [{dir :_ force :force whatif :whatif delete :delete bucket :bucket region :region profile :profile verbose :verbose}]
  (go
    (if (not= (count dir) 1)
      ["<dir> parameter required." nil]

;;;;   limitations under the License.

(ns biblecli.commands.bucketsync
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:require [cljs.core.async :refer [to-chan chan put! tap mult <! buffer onto-chan] :as async]
            [cljs.nodejs :refer [require process]]
            [clojure.string :as s]))

