[pbs-devel] [PATCH v3 proxmox-backup 8/9] api2: add name of mount-point to DatastoreMountInfo

Dominik Csapak d.csapak at proxmox.com
Fri Sep 11 13:08:31 CEST 2020


comment inline

On 8/28/20 10:46 AM, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
> for the removal of dirs the id/name is needed in the frontend, therefore it has to be returned by the api
> 
>   src/api2/node/disks/directory.rs | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
> index 0d9ddeef..1f3cb0ff 100644
> --- a/src/api2/node/disks/directory.rs
> +++ b/src/api2/node/disks/directory.rs
> @@ -34,6 +34,8 @@ pub struct DatastoreMountInfo {
>       pub unitfile: String,
>       /// The mount path.
>       pub path: String,
> +    /// The name of the mount.
> +    pub id: String,
>       /// The mounted device.
>       pub device: String,
>       /// File system type
> @@ -76,6 +78,7 @@ pub fn  list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
>           let item = item?;
>           let name = item.file_name().to_string_lossy().to_string();
>   
> +        let id = String::from(MOUNT_NAME_REGEX.captures(&name).unwrap().get(1).map_or("", |m| m.as_str()));

i find that line a little weird because you mix unwrap with a map_or here

either we say that it always must match (else we would be in that loop)
then we can always use unwrap here

or we actually check if it matches, then the unwrap and the map_or has 
to be replaced by better error handling
(having an id as "" is not good imho, this will never work in the gui 
anyway)

>           let unitfile = format!("{}/{}", basedir, name);
>           let config = systemd::config::parse_systemd_mount(&unitfile)?;
>           let data: SystemdMountSection = config.lookup("Mount", "Mount")?;
> @@ -84,6 +87,7 @@ pub fn  list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
>               unitfile,
>               device: data.What,
>               path: data.Where,
> +            id,
>               filesystem: data.Type,
>               options: data.Options,
>           });
> 






More information about the pbs-devel mailing list