Skip to content

Commit e5ad128

Browse files
authored
Merge pull request #108 from jmariondev/no_crtime
Fall back to modified time if creation time of cached binaries is unavailable
2 parents 121938a + 5dc4315 commit e5ad128

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,21 @@ impl InputAction {
359359
if matches!(self.build_kind, BuildKind::Normal) && !self.force_compile {
360360
match fs::File::open(&built_binary_path) {
361361
Ok(built_binary_file) => {
362-
// Use ctime instead of mtime as cargo may copy an already
363-
// built binary (with old mtime) here:
364-
let built_binary_ctime = built_binary_file.metadata()?.created()?;
362+
// When possible, use creation time instead of modified time as cargo may copy
363+
// an already built binary (with old modified time):
364+
let built_binary_time = built_binary_file
365+
.metadata()?
366+
.created()
367+
.unwrap_or(built_binary_file.metadata()?.modified()?);
365368
match (
366369
fs::File::open(&self.script_path),
367370
fs::File::open(manifest_path),
368371
) {
369372
(Ok(script_file), Ok(manifest_file)) => {
370373
let script_mtime = script_file.metadata()?.modified()?;
371374
let manifest_mtime = manifest_file.metadata()?.modified()?;
372-
if built_binary_ctime.cmp(&script_mtime).is_ge()
373-
&& built_binary_ctime.cmp(&manifest_mtime).is_ge()
375+
if built_binary_time.cmp(&script_mtime).is_ge()
376+
&& built_binary_time.cmp(&manifest_mtime).is_ge()
374377
{
375378
debug!("Keeping old binary");
376379
return Ok(execute_command());

0 commit comments

Comments
 (0)