Skip to content

Commit

Permalink
randomize fetching order in sync_snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
drdo committed Jun 22, 2024
1 parent 24e4178 commit 985f998
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ humansize = "2"
indicatif = "0.17"
log = "0.4"
nix = { version = "0.28", features = ["process"] }
rand = "0.8"
ratatui = { version = "0.26", features = ["unstable-rendered-line-info", "unstable-widget-ref"] }
refinery = { version = "0.8", features = ["rusqlite-bundled"] }
rusqlite = { version = "0.31", features = ["bundled", "functions", "trace"] }
Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use directories::ProjectDirs;
use flexi_logger::{FileSpec, LogSpecification, Logger, WriteMode};
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use log::{error, info, trace};
use rand::seq::SliceRandom;
use rand::thread_rng;
use ratatui::backend::{Backend, CrosstermBackend};
use ratatui::layout::Size;
use ratatui::style::Stylize;
Expand Down Expand Up @@ -297,10 +299,12 @@ fn sync_snapshots(
}

let db_snapshots = cache.get_snapshots()?;
repo_snapshots
let mut missing_snapshots = repo_snapshots
.into_iter()
.filter(|s| !db_snapshots.contains(s))
.collect()
.collect::<Vec<_>>();
missing_snapshots.shuffle(&mut thread_rng());
missing_snapshots
};

let total_missing_snapshots = match missing_snapshots.len() {
Expand Down

0 comments on commit 985f998

Please sign in to comment.