fix: clear old revisions

This commit is contained in:
2026-02-03 17:24:13 -08:00
parent c48880d0ca
commit a1a1466116
5 changed files with 85 additions and 1 deletions

View File

@@ -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,

View File

@@ -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(())
}
}