Skip to main content

lease_held_by_other

Function lease_held_by_other 

Source
pub fn lease_held_by_other(
    current: &str,
    lease: &str,
    aliases: &[String],
) -> bool
Expand description

Whether kopia’s currently-recorded maintenance owner is a DIFFERENT owner than us — i.e. neither our own lease’s owner nor one of our recognized Ownership::owner_aliases (the migration path: a repo whose managed Maintenance moved to a new lease format still recognizes the owner it used to stamp as itself, so the transition claims and re-stamps rather than yielding to what would otherwise look like a foreign owner).

current is empty for a never-run repository (kopia’s own “no owner set” state) — never “held by another”.

use kopiur_api::maintenance::{kopia_owner_for_lease, lease_held_by_other};

let lease = "kopiur/east/media/nas";
let alias = "kopiur/media/nas"; // the pre-cluster lease this repo used to use
let mine = kopia_owner_for_lease(lease);
let legacy = kopia_owner_for_lease(alias);

// Never-run repository: empty owner is never "held by another".
assert!(!lease_held_by_other("", lease, &[]));
// Already ours: not held by another.
assert!(!lease_held_by_other(&mine, lease, &[]));
// The recognized alias's owner: treated as self (migration path).
assert!(!lease_held_by_other(&legacy, lease, &[alias.to_string()]));
// The SAME string but the alias isn't registered: a genuine foreign owner.
assert!(lease_held_by_other(&legacy, lease, &[]));
// Any other owner: foreign.
assert!(lease_held_by_other("someone@else", lease, &[alias.to_string()]));