Add repo remove command

This commit is contained in:
Joscha 2025-05-03 00:41:30 +02:00
parent f77db3c6f8
commit efafc085f3
4 changed files with 29 additions and 2 deletions

View file

@ -12,7 +12,7 @@ pub use crate::repo::VERSION as REPO_VERSION;
pub use self::{
datadir::{LockedDataDir, UnlockedDataDir},
v1::{State, VERSION, add_repo, load_repo, load_repo_version, load_state, tidy},
v1::{State, VERSION, add_repo, load_repo, load_repo_version, load_state, remove_repo, tidy},
};
fn migrate(dir: &LockedDataDir) -> anyhow::Result<()> {

View file

@ -91,7 +91,8 @@ pub fn remove_repo(dir: &LockedDataDir, id: RepoId) -> anyhow::Result<()> {
state.repos.remove(&id);
save_state(dir, state)?;
// TODO Check if this works with read-only files
// This seems to work even with read-only files, so it should work fine for
// bare git repos. I don't expect to encounter read-only directories.
fs::remove_dir_all(repo_dir(dir, id))?;
Ok(())