@@ -98,7 +98,11 @@ impl CacheImpl {
9898 }
9999}
100100
101- type FilePathWithMTimeCTime = ( PathBuf , SystemTime , SystemTime ) ;
101+ /// Represents a file path with its modification time and optional creation time.
102+ /// Creation time (ctime) is optional because many Linux filesystems (ext4, etc.)
103+ /// don't support file creation time, causing metadata.created() to return Err.
104+ /// See: https://github.com/microsoft/python-environment-tools/issues/223
105+ type FilePathWithMTimeCTime = ( PathBuf , SystemTime , Option < SystemTime > ) ;
102106
103107struct CacheEntryImpl {
104108 cache_directory : Option < PathBuf > ,
@@ -120,9 +124,13 @@ impl CacheEntryImpl {
120124 // Check if any of the exes have changed since we last cached this.
121125 for symlink_info in self . symlinks . lock ( ) . unwrap ( ) . iter ( ) {
122126 if let Ok ( metadata) = symlink_info. 0 . metadata ( ) {
123- if metadata. modified ( ) . ok ( ) != Some ( symlink_info. 1 )
124- || metadata. created ( ) . ok ( ) != Some ( symlink_info. 2 )
125- {
127+ let mtime_changed = metadata. modified ( ) . ok ( ) != Some ( symlink_info. 1 ) ;
128+ // Only check ctime if we have it stored (may be None on Linux)
129+ let ctime_changed = match symlink_info. 2 {
130+ Some ( stored_ctime) => metadata. created ( ) . ok ( ) != Some ( stored_ctime) ,
131+ None => false , // Can't check ctime if we don't have it
132+ } ;
133+ if mtime_changed || ctime_changed {
126134 trace ! (
127135 "Symlink {:?} has changed since we last cached it. original mtime & ctime {:?}, {:?}, current mtime & ctime {:?}, {:?}" ,
128136 symlink_info. 0 ,
@@ -168,10 +176,10 @@ impl CacheEntry for CacheEntryImpl {
168176 let mut symlinks = vec ! [ ] ;
169177 for symlink in environment. symlinks . clone ( ) . unwrap_or_default ( ) . iter ( ) {
170178 if let Ok ( metadata) = symlink. metadata ( ) {
171- // We only care if we have the information
172- if let ( Some ( modified ) , Some ( created ) ) =
173- ( metadata . modified ( ) . ok ( ) , metadata. created ( ) . ok ( ) )
174- {
179+ // We require mtime, but ctime is optional (not available on all Linux filesystems)
180+ // See: https://github.com/microsoft/python-environment-tools/issues/223
181+ if let Ok ( modified) = metadata. modified ( ) {
182+ let created = metadata . created ( ) . ok ( ) ; // May be None on Linux
175183 symlinks. push ( ( symlink. clone ( ) , modified, created) ) ;
176184 }
177185 }
0 commit comments