Skip to content

Commit

Permalink
Merge pull request #1494 from jqnatividad/autocheck-for-updates-10per…
Browse files Browse the repository at this point in the history
…cent

Autocheck for updates 10% of the time
  • Loading branch information
jqnatividad authored Dec 25, 2023
2 parents 3ae8ab4 + 1297648 commit fb71610
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
58 changes: 29 additions & 29 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ Please choose one of the following {num_commands} commands:
sponsored by datHere - Data Infrastructure Engineering (https://qsv.datHere.com)
"#
);
_ = util::qsv_check_for_update(true, false);

// if no command is specified, auto-check for updates 10% of the time
let mut rng = fastrand::Rng::new(); //DevSkim: ignore DS148264
if rng.usize(0..10) == 0 {
_ = util::qsv_check_for_update(true, false);
}
util::log_end(qsv_args, now);
QsvExitCode::Good
},
Expand Down
2 changes: 1 addition & 1 deletion src/maindp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn main() -> QsvExitCode {
Please choose one of the following commands:",
command_list!()
));
_ = util::qsv_check_for_update(true, false);

util::log_end(qsv_args, now);
QsvExitCode::Good
},
Expand Down
7 changes: 6 additions & 1 deletion src/mainlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ fn main() -> QsvExitCode {
Please choose one of the following commands:",
command_list!()
));
_ = util::qsv_check_for_update(true, false);

// if no command is specified, auto-check for updates 10% of the time
let mut rng = fastrand::Rng::new(); //DevSkim: ignore DS148264
if rng.usize(0..10) == 0 {
_ = util::qsv_check_for_update(true, false);
}
util::log_end(qsv_args, now);
QsvExitCode::Good
},
Expand Down

0 comments on commit fb71610

Please sign in to comment.