Also changed expiration date to show "Never" instead of unix epoch in the pasta list, and renamed a few variables in animalnumbers.rs to make the function more readable.
This commit is contained in:
Daniel Szabo 2022-05-09 22:36:13 +01:00
parent 9e4940eb44
commit cd2eea30ce
3 changed files with 30 additions and 28 deletions

View file

@ -390,15 +390,18 @@ fn remove_expired(pastas: &mut Vec<Pasta>) {
} as i64;
pastas.retain(|p| {
// delete the files too
if p.expiration < timenow {
// expiration is `never` or not reached
if p.expiration == 0 || p.expiration > timenow {
// keep
true
} else {
// remove the file itself
fs::remove_file(format!("./pasta_data/{}/{}", p.id_as_animals(), p.file));
// and remove the containing directory
fs::remove_dir(format!("./pasta_data/{}/", p.id_as_animals()));
};
p.expiration == 0 || p.expiration > timenow
// remove
false
}
});
}