Skip to content

Commit

Permalink
Fix throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Dec 1, 2024
1 parent 7682786 commit 8982772
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/db/sync.ml
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,6 @@ let sync_folder ~source ~collection_id ~(folder : Item.t) idb =
enable_images = true;
}
in
(* Throttle queries *)
let* () =
let timer, timeout = Fut.create () in
let _ = G.set_timeout ~ms:50 (fun () -> timeout (Ok ())) in
timer
in
let* { Api.Items.start_index = _; items; _ } =
query source (module Api.Items) req ()
in
Expand Down Expand Up @@ -484,6 +478,12 @@ let sync_v2 ~report ~(source : Source.connexion) idb =
in
let renaming () = Queue.length queue + !running_jobs in
let rec assign_work () =
(* Throttle queries *)
let* () =
let timer, timeout = Fut.create () in
let _ = G.set_timeout ~ms:125 (fun () -> timeout (Ok ())) in
timer
in
max_queue_length := max !max_queue_length (Queue.length queue);
let () =
report
Expand Down

0 comments on commit 8982772

Please sign in to comment.