Skip to content

Commit 01ada53

Browse files
committed
Don't use sleep_ms
1 parent fd08012 commit 01ada53

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/bin/update-downloads.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate time;
77

88
use std::env;
99
use std::collections::HashMap;
10-
use time::Duration;
10+
use std::time::Duration;
1111

1212
use cargo_registry::{VersionDownload, Version, Model};
1313

@@ -17,14 +17,14 @@ static LIMIT: i64 = 1000;
1717
fn main() {
1818
let daemon = env::args().nth(1).as_ref().map(|s| &s[..])
1919
== Some("daemon");
20-
let sleep = env::args().nth(2).map(|s| s.parse::<u32>().unwrap());
20+
let sleep = env::args().nth(2).map(|s| s.parse().unwrap());
2121
loop {
2222
let conn = postgres::Connection::connect(&env("DATABASE_URL")[..],
2323
&postgres::SslMode::None).unwrap();
2424
update(&conn).unwrap();
2525
drop(conn);
2626
if daemon {
27-
std::thread::sleep_ms(sleep.unwrap() * 1000);
27+
std::thread::sleep(Duration::new(sleep.unwrap(), 0));
2828
} else {
2929
break
3030
}
@@ -63,11 +63,12 @@ fn update(conn: &postgres::GenericConnection) -> postgres::Result<()> {
6363

6464
fn collect(tx: &postgres::Transaction,
6565
rows: &mut postgres::rows::Rows) -> postgres::Result<Option<i32>> {
66+
use time::Duration;
6667

6768
// Anything older than 24 hours ago will be frozen and will not be queried
6869
// against again.
6970
let cutoff = time::now_utc().to_timespec();
70-
let cutoff = cutoff + Duration::days(-1);
71+
let cutoff = cutoff + Duration::days(1);
7172

7273
let mut map = HashMap::new();
7374
for row in rows.iter() {

0 commit comments

Comments
 (0)