Skip to content

Commit

Permalink
fix: chrono deprecation warnings (#558)
Browse files Browse the repository at this point in the history
Fixes `chrono` deprecation warnings introduced in 0.4.35.
  • Loading branch information
baszalmstra authored Mar 7, 2024
1 parent a0e4647 commit cef23f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bytes = "1.5.0"
bzip2 = "0.4.4"
cache_control = "0.2.0"
cfg-if = "1.0"
chrono = { version = "0.4.34", default-features = false, features = [
chrono = { version = "0.4.35", default-features = false, features = [
"std",
"serde",
"alloc",
Expand Down
7 changes: 2 additions & 5 deletions crates/rattler_conda_types/src/utils/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ impl<'de> DeserializeAs<'de, chrono::DateTime<chrono::Utc>> for Timestamp {
};

// Convert the timestamp to a UTC timestamp
Ok(chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(
chrono::NaiveDateTime::from_timestamp_micros(microseconds)
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))?,
chrono::Utc,
))
chrono::DateTime::from_timestamp_micros(microseconds)
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))
}
}

Expand Down
7 changes: 2 additions & 5 deletions crates/rattler_lock/src/utils/serde/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ impl<'de> DeserializeAs<'de, chrono::DateTime<chrono::Utc>> for Timestamp {
};

// Convert the timestamp to a UTC timestamp
Ok(chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(
chrono::NaiveDateTime::from_timestamp_micros(microseconds)
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))?,
chrono::Utc,
))
chrono::DateTime::from_timestamp_micros(microseconds)
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/rattler_repodata_gateway/src/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ async fn repodata_from_file(
///
/// The checks to see if a `.zst` and/or `.bz2` file exist are performed by doing a HEAD request to
/// the respective URLs. The result of these are cached.
#[instrument(err, skip_all, fields(subdir_url, cache_path = %cache_path.display()))]
#[instrument(err, skip_all, fields(subdir_url, cache_path = % cache_path.display()))]
pub async fn fetch_repo_data(
subdir_url: Url,
client: reqwest_middleware::ClientWithMiddleware,
Expand Down Expand Up @@ -441,7 +441,7 @@ pub async fn fetch_repo_data(
has_bz2: variant_availability.has_bz2,
has_jlap: variant_availability.has_jlap,
jlap: Some(state),
.. cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
..cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
};

let cache_state = tokio::task::spawn_blocking(move || {
Expand Down Expand Up @@ -528,7 +528,7 @@ pub async fn fetch_repo_data(
has_bz2: variant_availability.has_bz2,
has_jlap: variant_availability.has_jlap,
jlap: jlap_state,
.. cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
..cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
};

let cache_state = tokio::task::spawn_blocking(move || {
Expand Down Expand Up @@ -737,7 +737,7 @@ pub async fn check_variant_availability(
) -> VariantAvailability {
// Determine from the cache which variant are available. This is currently cached for a maximum
// of 14 days.
let expiration_duration = chrono::Duration::days(14);
let expiration_duration = chrono::TimeDelta::try_days(14).expect("14 days is a valid duration");
let has_zst = cache_state
.and_then(|state| state.has_zst.as_ref())
.and_then(|value| value.value(expiration_duration))
Expand Down

0 comments on commit cef23f8

Please sign in to comment.