Bugfix - #11
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:
parent
9e4940eb44
commit
cd2eea30ce
3 changed files with 30 additions and 28 deletions
13
src/main.rs
13
src/main.rs
|
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue