Match on version constants instead of number literals

This commit is contained in:
Joscha 2025-05-02 01:27:03 +02:00
parent 2c5ff584db
commit 0baf79cb8c
2 changed files with 3 additions and 3 deletions

View file

@ -19,7 +19,7 @@ fn migrate(dir: &LockedDataDir) -> anyhow::Result<()> {
loop {
let version = dir.read_version().context("failed to migrate data dir")?;
match version {
0 => v0::migrate(dir),
v0::VERSION => v0::migrate(dir),
_ => break Ok(()),
}
.with_context(|| format!("failed to migrate data dir from version {version}"))?;

View file

@ -50,8 +50,8 @@ pub fn load(path: &Path) -> anyhow::Result<Repo> {
#[expect(unused_qualifications)]
let repo = match version {
0 => v0::Repo::load().migrate(),
1 => v1::Repo::load(&repository)?.migrate(),
v0::VERSION => v0::Repo::load().migrate(),
v1::VERSION => v1::Repo::load(&repository)?.migrate(),
n => bail!("invalid repo version {n}"),
};