) -> Result<Vec<GroupListItem>, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store: store,
+ ns: ns.unwrap_or_default(),
};
let list_all = !check_ns_privs_full(
PRIV_DATASTORE_BACKUP,
)?;
- let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?;
+ let datastore = DataStore::lookup_datastore(&store_with_ns.store, Some(Operation::Read))?;
datastore
- .iter_backup_groups(ns.clone())? // FIXME: Namespaces and recursion parameters!
+ .iter_backup_groups(store_with_ns.ns.clone())? // FIXME: Namespaces and recursion parameters!
.try_fold(Vec::new(), |mut group_info, group| {
let group = group?;
- let owner = match datastore.get_owner(&ns, group.as_ref()) {
+ let owner = match datastore.get_owner(&store_with_ns.ns, group.as_ref()) {
Ok(auth_id) => auth_id,
Err(err) => {
eprintln!(
})
.to_owned();
- let note_path = get_group_note_path(&datastore, &ns, group.as_ref());
+ let note_path = get_group_note_path(&datastore, &store_with_ns.ns, group.as_ref());
let comment = file_read_firstline(¬e_path).ok();
group_info.push(GroupListItem {
) -> Result<Value, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
+ let store_with_ns = DatastoreWithNamespace {
+ store,
+ ns: ns.unwrap_or_default(),
+ };
let datastore = check_privs_and_load_store(
- &DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
- },
+ &store_with_ns,
&auth_id,
PRIV_DATASTORE_MODIFY,
PRIV_DATASTORE_PRUNE,
&group,
)?;
- if !datastore.remove_backup_group(&ns, &group)? {
+ if !datastore.remove_backup_group(&store_with_ns.ns, &group)? {
bail!("group only partially deleted due to protected snapshots");
}
) -> Result<Vec<BackupContent>, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store: store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&backup_dir.group,
)?;
- let snapshot = datastore.backup_dir(ns, backup_dir)?;
+ let snapshot = datastore.backup_dir(store_with_ns.ns, backup_dir)?;
let info = BackupInfo::new(snapshot)?;
) -> Result<Value, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store: store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&backup_dir.group,
)?;
- let snapshot = datastore.backup_dir(ns, backup_dir)?;
+ let snapshot = datastore.backup_dir(store_with_ns.ns, backup_dir)?;
snapshot.destroy(false)?;
let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
+ store,
ns: ns.clone(),
};
PRIV_DATASTORE_BACKUP,
)?;
- let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?;
+ let datastore = DataStore::lookup_datastore(&store_with_ns.store, Some(Operation::Read))?;
// FIXME: filter also owner before collecting, for doing that nicely the owner should move into
// backup group and provide an error free (Err -> None) accessor
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
+ store,
ns: ns.clone(),
};
PRIV_DATASTORE_BACKUP,
)?;
- let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?;
+ let datastore = DataStore::lookup_datastore(&store_with_ns.store, Some(Operation::Read))?;
let ignore_verified = ignore_verified.unwrap_or(true);
let worker_id;
(Some(backup_type), Some(backup_id), Some(backup_time)) => {
worker_id = format!(
"{}:{}/{}/{}/{:08X}",
- store,
+ store_with_ns.store,
ns.display_as_path(),
backup_type,
backup_id,
(Some(backup_type), Some(backup_id), None) => {
worker_id = format!(
"{}:{}/{}/{}",
- store,
+ store_with_ns.store,
ns.display_as_path(),
backup_type,
backup_id
}
(None, None, None) => {
worker_id = if ns.is_root() {
- store.clone()
+ format!("{}", store_with_ns.store)
} else {
- format!("{store}:{}", ns.display_as_path())
+ format!("{}:{}", store_with_ns.store, ns.display_as_path())
};
}
_ => bail!("parameters do not specify a backup group or snapshot"),
rpcenv: &mut dyn RpcEnvironment,
) -> Result<Value, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&group,
)?;
- let worker_id = format!("{}:{}:{}", store, ns, group);
- let group = datastore.backup_group(ns, group);
+ let worker_id = format!("{}:{}:{}", store_with_ns.store, store_with_ns.ns, group);
+ let group = datastore.backup_group(store_with_ns.ns.clone(), group);
let mut prune_result = Vec::new();
rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<ArchiveEntry>, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&backup_dir.group,
)?;
- let backup_dir = datastore.backup_dir(ns, backup_dir)?;
+ let backup_dir = datastore.backup_dir(store_with_ns.ns.clone(), backup_dir)?;
let file_name = CATALOG_NAME;
rpcenv: &mut dyn RpcEnvironment,
) -> Result<String, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&backup_group,
)?;
- let note_path = get_group_note_path(&datastore, &ns, &backup_group);
+ let note_path = get_group_note_path(&datastore, &store_with_ns.ns, &backup_group);
Ok(file_read_optional_string(note_path)?.unwrap_or_else(|| "".to_owned()))
}
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&store_with_ns,
&backup_group,
)?;
- let note_path = get_group_note_path(&datastore, &ns, &backup_group);
+ let note_path = get_group_note_path(&datastore, &store_with_ns.ns, &backup_group);
replace_file(note_path, notes.as_bytes(), CreateOptions::new(), false)?;
Ok(())
rpcenv: &mut dyn RpcEnvironment,
) -> Result<String, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
store: store.clone(),
- ns: ns.clone(),
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&backup_dir.group,
)?;
- let backup_dir = datastore.backup_dir(ns, backup_dir)?;
+ let backup_dir = datastore.backup_dir(store_with_ns.ns.clone(), backup_dir)?;
let (manifest, _) = backup_dir.load_manifest()?;
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&backup_dir.group,
)?;
- let backup_dir = datastore.backup_dir(ns, backup_dir)?;
+ let backup_dir = datastore.backup_dir(store_with_ns.ns.clone(), backup_dir)?;
backup_dir
.update_manifest(|manifest| {
rpcenv: &mut dyn RpcEnvironment,
) -> Result<bool, Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&store_with_ns,
&backup_dir.group,
)?;
- let backup_dir = datastore.backup_dir(ns, backup_dir)?;
+ let backup_dir = datastore.backup_dir(store_with_ns.ns.clone(), backup_dir)?;
Ok(backup_dir.is_protected())
}
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let datastore = check_privs_and_load_store(
&store_with_ns,
&backup_dir.group,
)?;
- let backup_dir = datastore.backup_dir(ns, backup_dir)?;
+ let backup_dir = datastore.backup_dir(store_with_ns.ns.clone(), backup_dir)?;
datastore.update_protection(&backup_dir, protected)
}
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
- let ns = ns.unwrap_or_default();
let store_with_ns = DatastoreWithNamespace {
- store: store.clone(),
- ns: ns.clone(),
+ store,
+ ns: ns.unwrap_or_default(),
};
let owner_check_required = check_ns_privs_full(
&store_with_ns,
PRIV_DATASTORE_BACKUP,
)?;
- let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?;
+ let datastore = DataStore::lookup_datastore(&store_with_ns.store, Some(Operation::Write))?;
- let backup_group = datastore.backup_group(ns, backup_group);
+ let backup_group = datastore.backup_group(store_with_ns.ns, backup_group);
if owner_check_required {
let owner = backup_group.get_owner()?;