Handle broken utimes() on Android

Closes https://github.com/ankidroid/Anki-Android/issues/12827
Closes https://github.com/ankidroid/Anki-Android/issues/12974
This commit is contained in:
Damien Elmes 2022-12-28 16:32:34 +10:00
parent 272d53079f
commit 4c5a2461d0

View File

@ -349,7 +349,13 @@ where
.duration_since(time::UNIX_EPOCH)
.unwrap()
.as_secs() as i64;
utime::set_file_times(&dst_path, secs, secs)?;
if let Err(err) = utime::set_file_times(&dst_path, secs, secs) {
// The libc utimes() call fails on (some? all?) Android devices. Since we don't
// do automatic expiry yet, we can safely ignore the error.
if !cfg!(target_os = "android") {
return Err(err.into());
}
}
}
Ok(())