Leave a team, delete a vault; keep tests out of the real settings

- A hub test unset LUNE_HOME for the whole test run, so later tests saved
  into the real user's config. Tests now always keep their own settings
  folder.
- Leaving a team: `lunesync leave` and the app's Leave hand over and remove
  this device there; a hub that's gone can be forgotten (folders stay).
- Deleting a vault (owner): everyone is removed the usual way, the history
  is archived on the hub and the name is freed. Canvas asks first.
- Connect this Mac says what to do when Lune isn't installed.
- Update checks skip http hubs instead of failing for all of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 14:36:46 +07:00
parent 7d1437e3ec
commit 4f6414b256
16 changed files with 278 additions and 10 deletions

View File

@@ -210,6 +210,36 @@ pub fn leave(config: &mut Config, link: &HubLink, d: &Departure) -> Result<Strin
}
}
/// Leaves one team's hub on this device. If the hub answers, this device removes itself there, which hands
/// over anything unshared and leaves its vaults the usual way (A6). If the hub is gone or no longer knows this
/// device, `forget` drops it from this device only: its folders stay where they are, no longer synced.
pub fn leave_hub(config: &mut Config, url: &str, forget: bool) -> Result<Vec<String>> {
let Some(link) = config.hub(url).cloned() else { bail!("this device isn't on the hub at {url}") };
let label = config.device_label();
let reached = link.remove_device(&label, None).and_then(|_| link.me());
let mut said = vec![];
match reached {
Ok(me) => {
for d in &me.leaving {
said.push(leave(config, &link, d)?);
}
}
Err(e) if !forget => {
bail!("can't reach the hub at {url} ({e:#}). If that team is gone for good, forget it on this device only")
}
Err(_) => said.push(format!("Couldn't reach {url}, so this device only forgot it; its folders stay, no longer synced")),
}
for vc in config.vaults.iter().filter(|v| v.hub_url.as_deref() == Some(url)) {
let _ = set_read_only(&vc.path, false);
said.push(format!("{} stays at {}, no longer synced", vc.name, vc.path.display()));
}
config.vaults.retain(|v| v.hub_url.as_deref() != Some(url));
config.hubs.retain(|h| h.url != url);
config.save()?;
said.push(format!("Left the team at {url}"));
Ok(said)
}
/// What uninstalling did, in plain words.
#[derive(Debug, Default, Serialize)]
pub struct Uninstalled {