From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 46E1D61036
 for <pbs-devel@lists.proxmox.com>; Fri, 11 Sep 2020 13:09:22 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 3BB1E24238
 for <pbs-devel@lists.proxmox.com>; Fri, 11 Sep 2020 13:08:52 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id A6B3F2422B
 for <pbs-devel@lists.proxmox.com>; Fri, 11 Sep 2020 13:08:51 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 71DD144B61
 for <pbs-devel@lists.proxmox.com>; Fri, 11 Sep 2020 13:08:51 +0200 (CEST)
To: pbs-devel@lists.proxmox.com
References: <20200828084658.22057-1-h.laimer@proxmox.com>
 <20200828084658.22057-9-h.laimer@proxmox.com>
From: Dominik Csapak <d.csapak@proxmox.com>
Message-ID: <71e115e4-4015-ba15-224f-dc8f05e8f469@proxmox.com>
Date: Fri, 11 Sep 2020 13:08:31 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101
 Thunderbird/81.0
MIME-Version: 1.0
In-Reply-To: <20200828084658.22057-9-h.laimer@proxmox.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 2.324 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -3.576 Looks like a legit reply (A)
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [directory.rs]
Subject: Re: [pbs-devel] [PATCH v3 proxmox-backup 8/9] api2: add name of
 mount-point to DatastoreMountInfo
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 11 Sep 2020 11:09:22 -0000

comment inline

On 8/28/20 10:46 AM, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer@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,
>           });
>