Skip to content

Commit 5617477

Browse files
authored
Rollup merge of #46421 - mnd:fix-build-for-guix, r=alexcrichton
build_helper: destination file can't be up to date when not exists Function "up_to_date" return incorrect result if mtime for all fetched sources is set to epoch time. Add existence check to function. This fix required for a [Guix](https://www.gnu.org/software/guix/) package because a Nix builder set mtime of all sources to epoch time.
2 parents 662f902 + f2df1f5 commit 5617477

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/build_helper/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ pub fn mtime(path: &Path) -> FileTime {
190190
///
191191
/// Uses last-modified time checks to verify this.
192192
pub fn up_to_date(src: &Path, dst: &Path) -> bool {
193+
if !dst.exists() {
194+
return false;
195+
}
193196
let threshold = mtime(dst);
194197
let meta = match fs::metadata(src) {
195198
Ok(meta) => meta,

0 commit comments

Comments
 (0)