@@ -20,6 +20,7 @@ use std::env;
2020use std:: ffi:: { OsStr , OsString } ;
2121use std:: path:: Path ;
2222use std:: sync:: { Arc , LazyLock } ;
23+ use std:: time:: SystemTime ;
2324
2425use async_lock:: RwLock ;
2526use bytes:: Bytes ;
@@ -49,7 +50,7 @@ use tokio::sync::{Barrier, Semaphore};
4950use tokio:: time:: sleep;
5051use tokio_stream:: StreamExt ;
5152use tokio_stream:: wrappers:: ReadDirStream ;
52- use tracing:: Instrument ;
53+ use tracing:: { Instrument , debug } ;
5354
5455const VALID_HASH : & str = "0123456789abcdef000000000000000000010000000000000123456789abcdef" ;
5556
@@ -1465,3 +1466,40 @@ async fn safe_small_safe_eviction() -> Result<(), Error> {
14651466
14661467 Ok ( ( ) )
14671468}
1469+
1470+ #[ nativelink_test]
1471+ async fn add_too_early_files ( ) -> Result < ( ) , Error > {
1472+ let content_path = make_temp_path ( "content_path" ) ;
1473+ let temp_path = make_temp_path ( "temp_path" ) ;
1474+
1475+ let demo_file_folder = format ! ( "{content_path}/s" ) ;
1476+ fs:: create_dir_all ( & demo_file_folder) . await ?;
1477+ let demo_file_path = format ! ( "{demo_file_folder}/foo" ) ;
1478+ std:: fs:: write ( & demo_file_path, "demo text" )
1479+ . err_tip ( || format ! ( "writing to {demo_file_path}" ) ) ?;
1480+ debug ! ( %demo_file_path, "demo file path" ) ;
1481+
1482+ // Add 60 seconds to the access time to trigger the logging message about access times
1483+ fs_set_times:: set_atime (
1484+ & demo_file_path,
1485+ SystemTime :: now ( )
1486+ . checked_add ( Duration :: from_secs ( 60 ) )
1487+ . unwrap ( )
1488+ . into ( ) ,
1489+ ) ?;
1490+
1491+ FilesystemStore :: < FileEntryImpl > :: new ( & FilesystemSpec {
1492+ content_path : content_path. clone ( ) ,
1493+ temp_path : temp_path. clone ( ) ,
1494+ read_buffer_size : 1 ,
1495+ ..Default :: default ( )
1496+ } )
1497+ . await
1498+ . err_tip ( || "during FileSystemStore::new" ) ?;
1499+
1500+ assert ! ( logs_contain(
1501+ "File access time newer than FilesystemStore start time file_name=foo atime=20"
1502+ ) ) ;
1503+
1504+ Ok ( ( ) )
1505+ }
0 commit comments