Skip to content

Commit c604e7e

Browse files
edward-shenmeta-codesync[bot]
authored andcommitted
Replace Duration::from_secs(3600) to Duration::from_hours(1) (#2059)
Summary: Pull Request resolved: #2059 Rust 1.91 introduced `Duration::from_hours`. This diff replaces some instances of `Duration::from_secs` with the corresponding `Duration::from_hours`. Reviewed By: dtolnay Differential Revision: D88441312 fbshipit-source-id: b4208c4b38a2f5b2b8471ab04dbc9d30b71b631d
1 parent 86f937c commit c604e7e

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

monarch_conda/src/diff.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ mod tests {
439439
// Test various mtime scenarios
440440
let base_timestamp = 1640995200;
441441
let test_base_time = UNIX_EPOCH + Duration::from_secs(base_timestamp);
442-
let old_time = test_base_time - Duration::from_secs(3600); // 1 hour before base
442+
let old_time = test_base_time - Duration::from_hours(1); // 1 hour before base
443443
let new_time = test_base_time + Duration::from_secs(7200); // 2 hours after base (beyond slop)
444444

445445
// Files older than base should be considered equal
@@ -492,13 +492,13 @@ mod tests {
492492

493493
let base_timestamp = 1640995200;
494494
let test_base_time = UNIX_EPOCH + Duration::from_secs(base_timestamp);
495-
let update_start = test_base_time + Duration::from_secs(3600); // Update window start
495+
let update_start = test_base_time + Duration::from_hours(1); // Update window start
496496
let update_end = test_base_time + Duration::from_mins(61); // Update window end
497497
let in_window_time = update_start + Duration::from_secs(30); // Inside update window
498-
let after_window_time = update_end + Duration::from_secs(3600); // After update window
498+
let after_window_time = update_end + Duration::from_hours(1); // After update window
499499

500500
// Files with mtimes in the update window should be ignored (treated as equal to old files)
501-
let old_time = base_time - Duration::from_secs(3600);
501+
let old_time = base_time - Duration::from_hours(1);
502502
assert_eq!(
503503
comparator(&in_window_time, &old_time),
504504
std::cmp::Ordering::Equal
@@ -738,7 +738,7 @@ mod tests {
738738

739739
let base_timestamp = base_time.duration_since(UNIX_EPOCH)?.as_secs();
740740
let update_window_time = UNIX_EPOCH + Duration::from_secs(base_timestamp + 3630); // In the middle of update window
741-
let old_time = base_time - Duration::from_secs(3600);
741+
let old_time = base_time - Duration::from_hours(1);
742742
let new_time = base_time + Duration::from_secs(7200);
743743

744744
// When update_window_time is the first arg (env1 context with update window),
@@ -814,7 +814,7 @@ mod tests {
814814
// But the mtime comparator should still work since the core history is the same
815815
let comparator = CondaFingerprint::mtime_comparator(&fingerprint1, &fingerprint2)?;
816816

817-
let old_time = base_time - Duration::from_secs(3600);
817+
let old_time = base_time - Duration::from_hours(1);
818818
let new_time = base_time + Duration::from_secs(7200);
819819

820820
// Basic mtime comparison should still work
@@ -928,7 +928,7 @@ mod tests {
928928
// Create mtime comparator and verify it works with large environments
929929
let comparator = CondaFingerprint::mtime_comparator(&fingerprint1, &fingerprint2)?;
930930

931-
let old_time = base_time - Duration::from_secs(3600);
931+
let old_time = base_time - Duration::from_hours(1);
932932
let new_time = base_time + Duration::from_secs(7200);
933933

934934
assert_eq!(comparator(&old_time, &old_time), std::cmp::Ordering::Equal);
@@ -984,7 +984,7 @@ mod tests {
984984
// Test exactly at the boundary points
985985
let one_sec_before_window = update_window_start - Duration::from_secs(1);
986986
let one_sec_after_window = update_window_end + Duration::from_secs(1);
987-
let old_time = base_time - Duration::from_secs(3600);
987+
let old_time = base_time - Duration::from_hours(1);
988988

989989
// Just before update window should be newer than old files
990990
assert_eq!(

monarch_conda/src/sync.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ mod tests {
875875

876876
// Modify a file in the source environment
877877
let modified_content = "modified test data\n";
878-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
878+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
879879
modify_file(
880880
src_env.path(),
881881
"bin/test-file",
@@ -919,7 +919,7 @@ mod tests {
919919

920920
// Add a new file to the source environment
921921
let new_file_content = "new file content\n";
922-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
922+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
923923
add_file(
924924
src_env.path(),
925925
"lib/new-file.txt",
@@ -966,7 +966,7 @@ mod tests {
966966
let dst_env = setup_conda_env(TempDir::new()?, base_time, None).await?;
967967

968968
// Create a new directory with a file in the source environment
969-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
969+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
970970
fs::create_dir(src_env.path().join("new_dir")).await?;
971971
add_file(
972972
src_env.path(),
@@ -1021,7 +1021,7 @@ mod tests {
10211021
fs::symlink("bin/test-file", src_env.path().join("link-to-test")).await?;
10221022

10231023
// Set a newer time for the symlink to ensure it's synced
1024-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
1024+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
10251025
set_mtime(&src_env.path().join("link-to-test"), newer_time).await?;
10261026

10271027
// Sync changes from source to destination
@@ -1061,7 +1061,7 @@ mod tests {
10611061
let dst_env = setup_conda_env(TempDir::new()?, base_time, None).await?;
10621062

10631063
// Add an extra file to the destination that doesn't exist in source
1064-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
1064+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
10651065
add_file(
10661066
dst_env.path(),
10671067
"extra-file.txt",
@@ -1099,7 +1099,7 @@ mod tests {
10991099
let dst_env = setup_conda_env(TempDir::new()?, base_time, None).await?;
11001100

11011101
// Add a .pyc file to the source.
1102-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
1102+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
11031103
add_file(
11041104
src_env.path(),
11051105
"lib/test.pyc",
@@ -1156,7 +1156,7 @@ mod tests {
11561156
let dst_env = setup_conda_env(TempDir::new()?, base_time, None).await?;
11571157

11581158
// Add an executable file to the source
1159-
let newer_time = base_time + Duration::from_secs(3600); // 1 hour later
1159+
let newer_time = base_time + Duration::from_hours(1); // 1 hour later
11601160
add_file(
11611161
src_env.path(),
11621162
"bin/executable",
@@ -1208,7 +1208,7 @@ mod tests {
12081208
let dst_env = setup_conda_env(TempDir::new()?, base_time, Some(dst_prefix)).await?;
12091209

12101210
// Add a text file with prefix references to the source
1211-
let newer_time = base_time + Duration::from_secs(3600);
1211+
let newer_time = base_time + Duration::from_hours(1);
12121212
let text_content = format!(
12131213
"#!/bin/bash\nexport PATH={}/bin:$PATH\necho 'Using prefix: {}'\n",
12141214
src_prefix, src_prefix
@@ -1264,7 +1264,7 @@ mod tests {
12641264
let dst_env = setup_conda_env(TempDir::new()?, base_time, Some(dst_prefix)).await?;
12651265

12661266
// Create a binary file with embedded prefix and null bytes
1267-
let newer_time = base_time + Duration::from_secs(3600);
1267+
let newer_time = base_time + Duration::from_hours(1);
12681268
let mut binary_content = Vec::new();
12691269
binary_content.extend_from_slice(b"\x7fELF"); // ELF magic number
12701270
binary_content.extend_from_slice(&[0u8; 10]); // null bytes to make it binary
@@ -1315,7 +1315,7 @@ mod tests {
13151315
let dst_env = setup_conda_env(TempDir::new()?, base_time, Some(dst_prefix)).await?;
13161316

13171317
// Create a symlink that points to a path with the source prefix
1318-
let newer_time = base_time + Duration::from_secs(3600);
1318+
let newer_time = base_time + Duration::from_hours(1);
13191319
let symlink_target = format!("{}/lib/target-file", src_prefix);
13201320
fs::symlink(&symlink_target, src_env.path().join("bin/link-to-target")).await?;
13211321
set_mtime(&src_env.path().join("bin/link-to-target"), newer_time).await?;
@@ -1350,7 +1350,7 @@ mod tests {
13501350
let dst_env = setup_conda_env(TempDir::new()?, base_time, Some(dst_prefix)).await?;
13511351

13521352
// Create a symlink that points to a relative path (should not be modified)
1353-
let newer_time = base_time + Duration::from_secs(3600);
1353+
let newer_time = base_time + Duration::from_hours(1);
13541354
let symlink_target = "relative/path/target";
13551355
fs::symlink(&symlink_target, src_env.path().join("bin/relative-link")).await?;
13561356
set_mtime(&src_env.path().join("bin/relative-link"), newer_time).await?;
@@ -1385,7 +1385,7 @@ mod tests {
13851385
let dst_env = setup_conda_env(TempDir::new()?, base_time, Some(dst_prefix)).await?;
13861386

13871387
// Create a binary file with embedded prefix and null bytes
1388-
let newer_time = base_time + Duration::from_secs(3600);
1388+
let newer_time = base_time + Duration::from_hours(1);
13891389
let mut binary_content = Vec::new();
13901390
binary_content.extend_from_slice(b"\x7fELF"); // ELF magic number
13911391
binary_content.extend_from_slice(&[0u8; 10]); // null bytes to make it binary

0 commit comments

Comments
 (0)