fix: clear old revisions
This commit is contained in:
@@ -22,6 +22,12 @@ pub enum ErrorKind {
|
||||
#[source]
|
||||
source: std::io::Error,
|
||||
},
|
||||
#[error("error clearing old revisions at {path}")]
|
||||
ClearRevisions {
|
||||
path: PathBuf,
|
||||
#[source]
|
||||
source: std::io::Error,
|
||||
},
|
||||
#[error("error persisting archive to {path}")]
|
||||
PersistError {
|
||||
path: PathBuf,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::fs::DirEntry;
|
||||
use std::io::BufWriter;
|
||||
use std::io::{self, BufWriter};
|
||||
use std::path::{self, Path};
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
@@ -52,6 +52,15 @@ impl StorageImpl for FSStorage {
|
||||
path = ?archive_path,
|
||||
"stored revision"
|
||||
);
|
||||
let remove_path = base_path().join(&format!("revision_{revision}.tar.gz"));
|
||||
match fs::remove_file(&remove_path) {
|
||||
Ok(_) => {}
|
||||
Err(e) => match e.kind() {
|
||||
io::ErrorKind::NotFound => {}
|
||||
_ => return Err(Error::clear_revisions(e, &remove_path)),
|
||||
},
|
||||
};
|
||||
tracing::debug!(revision, path = ?remove_path, "cleared revisions");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user