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:
@@ -241,6 +241,12 @@ impl HubLink {
|
||||
Ok(v["message"].as_str().unwrap_or_default().to_string())
|
||||
}
|
||||
|
||||
/// Deletes a vault (team owner); returns how many devices will hand over and remove their copy.
|
||||
pub fn delete_vault(&self, vault: &str) -> Result<usize> {
|
||||
let v: Value = self.post("/api/vaults/delete", json!({ "vault": vault }))?;
|
||||
Ok(v["devices"].as_u64().unwrap_or(0) as usize)
|
||||
}
|
||||
|
||||
pub fn vault_setting(&self, vault: &str, delete_from_devices: bool) -> Result<()> {
|
||||
let _: Value = self.post("/api/vaults/settings", json!({"vault": vault, "delete_from_devices": delete_from_devices}))?;
|
||||
Ok(())
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user