[pbs-devel] [RFC PATCH proxmox-backup 2/3] api: datastore: add upload_statistic to snapshot listing

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Nov 27 10:08:33 CET 2023


On Tue, Aug 01, 2023 at 11:29:53AM +0200, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> instead we could make a seperate api call that return just detailed info
> about a single snapshot on demand
>  pbs-api-types/src/datastore.rs |  3 +++
>  src/api2/admin/datastore.rs    | 22 +++++++++++++++++-----
>  2 files changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> index 41db680c..39e3c09a 100644
> --- a/pbs-api-types/src/datastore.rs
> +++ b/pbs-api-types/src/datastore.rs
> @@ -1138,6 +1138,9 @@ pub struct SnapshotListItem {
>      /// Protection from prunes
>      #[serde(default)]
>      pub protected: bool,
> +    /// Upload statistics
> +    #[serde(skip_serializing_if = "Option::is_none")]
> +    pub upload_statistic: Option<UploadStatistic>,

^ SnapshotListItem has since been made PartialEq, so UploadStatistic
also needs to derive it.

>  }
>  
>  #[api(
> diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
> index a95031e7..f5b47cf4 100644
> --- a/src/api2/admin/datastore.rs
> +++ b/src/api2/admin/datastore.rs
> @@ -35,11 +35,11 @@ use pbs_api_types::{
>      print_ns_and_snapshot, print_store_and_ns, Authid, BackupContent, BackupNamespace, BackupType,
>      Counts, CryptMode, DataStoreListItem, DataStoreStatus, GarbageCollectionStatus, GroupListItem,
>      KeepOptions, Operation, PruneJobOptions, RRDMode, RRDTimeFrame, SnapshotListItem,
> -    SnapshotVerifyState, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA,
> -    BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA, IGNORE_VERIFIED_BACKUPS_SCHEMA,
> -    MAX_NAMESPACE_DEPTH, NS_MAX_DEPTH_SCHEMA, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP,
> -    PRIV_DATASTORE_MODIFY, PRIV_DATASTORE_PRUNE, PRIV_DATASTORE_READ, PRIV_DATASTORE_VERIFY,
> -    UPID_SCHEMA, VERIFICATION_OUTDATED_AFTER_SCHEMA,
> +    SnapshotVerifyState, UploadStatistic, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA,
> +    BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA,
> +    IGNORE_VERIFIED_BACKUPS_SCHEMA, MAX_NAMESPACE_DEPTH, NS_MAX_DEPTH_SCHEMA, PRIV_DATASTORE_AUDIT,
> +    PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, PRIV_DATASTORE_PRUNE, PRIV_DATASTORE_READ,
> +    PRIV_DATASTORE_VERIFY, UPID_SCHEMA, VERIFICATION_OUTDATED_AFTER_SCHEMA,
>  };
>  use pbs_client::pxar::{create_tar, create_zip};
>  use pbs_config::CachedUserInfo;
> @@ -532,6 +532,16 @@ unsafe fn list_snapshots_blocking(
>  
>                  let size = Some(files.iter().map(|x| x.size.unwrap_or(0)).sum());
>  
> +                let upload_statistic = manifest.unprotected["chunk_upload_stats"].clone();
> +                let upload_statistic: Option<UploadStatistic> =

Note that `Value` as well as `&Value` are also both Deserialize*R*s,
so you can skip cloning the Value structure and go straight to the
`UploadStatistic` via:

    let upload_statistic = match Option::<UploadStatistic>::deserialize(
        &manifest.unprotected["chunk_upload_stats"],
    ) {
        ...
    }





More information about the pbs-devel mailing list