Fix backups failing on Android

This commit is contained in:
Damien Elmes 2022-06-27 15:27:51 +10:00
parent 0a7508f263
commit 6ff159304d

View File

@ -65,7 +65,17 @@ fn has_recent_backup(backup_folder: &Path, recent_mins: u32) -> Result<bool> {
Ok(read_dir(backup_folder)?
.filter_map(|res| res.ok())
.filter_map(|entry| entry.metadata().ok())
.filter_map(|meta| meta.created().ok())
.filter_map(|meta| {
// created time unsupported on Android
#[cfg(target_os = "android")]
{
meta.modified().ok()
}
#[cfg(not(target_os = "android"))]
{
meta.created().ok()
}
})
.filter_map(|time| now.duration_since(time).ok())
.any(|duration| duration.as_secs() < recent_secs))
}