mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-07-09 09:26:46 +00:00
api: datastore: factor out path decoding for catalog
The file path passed to the catalog is base64 encoded, with an exception for the root. Factor this check and decoding step out into a helper function to make it reusable when doing the same for lookups via the metadata archive instead of the catalog. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
2baa9f8fb8
commit
30ea695518
@ -1636,6 +1636,14 @@ pub fn upload_backup_log(
|
|||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn decode_path(path: &str) -> Result<Vec<u8>, Error> {
|
||||||
|
if path != "root" && path != "/" {
|
||||||
|
base64::decode(path).map_err(|err| format_err!("base64 decoding of path failed - {err}"))
|
||||||
|
} else {
|
||||||
|
Ok(vec![b'/'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
input: {
|
input: {
|
||||||
properties: {
|
properties: {
|
||||||
@ -1709,12 +1717,7 @@ pub async fn catalog(
|
|||||||
|
|
||||||
let mut catalog_reader = CatalogReader::new(reader);
|
let mut catalog_reader = CatalogReader::new(reader);
|
||||||
|
|
||||||
let path = if filepath != "root" && filepath != "/" {
|
let path = decode_path(&filepath)?;
|
||||||
base64::decode(filepath)?
|
|
||||||
} else {
|
|
||||||
vec![b'/']
|
|
||||||
};
|
|
||||||
|
|
||||||
catalog_reader.list_dir_contents(&path)
|
catalog_reader.list_dir_contents(&path)
|
||||||
})
|
})
|
||||||
.await?
|
.await?
|
||||||
|
Loading…
Reference in New Issue
Block a user