From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 8CF2F1FF13B for ; Wed, 22 Apr 2026 13:17:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CFE1B186A9; Wed, 22 Apr 2026 13:14:38 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v1 31/54] storage: simplify recently refactored logic in path_to_volume_id sub Date: Wed, 22 Apr 2026 13:12:57 +0200 Message-ID: <20260422111322.257380-32-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260422111322.257380-1-m.carrara@proxmox.com> References: <20260422111322.257380-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776856348726 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.084 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: YEYQ3OKSFETCYSGNITXAAN3YJEUXIVUQ X-Message-ID-Hash: YEYQ3OKSFETCYSGNITXAAN3YJEUXIVUQ X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Since the branches for all volume types except `images` do exactly the same thing, just return the result of the `parse_path_as_volid()` parsing function directly. In order to avoid unnecessary work for the other volume types, strip the volume type subdirectory from the given file path only for the `images` volume type. Signed-off-by: Max R. Carrara --- src/PVE/Storage.pm | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 3a716894..199a6375 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -730,16 +730,16 @@ sub path_to_volume_id { my $parse_volid_from_file_path = sub { my ($plugin, $sid, $scfg, $vtype) = @_; - my $vtype_subdir = plugin_get_vtype_subdir($scfg, $vtype); - - # Strip the vtype subdir from beginning of the current path - # so that we don't have to take it into account when parsing the file name - my $filename = $path; - if ($filename !~ s!^\Q$vtype_subdir\E!!) { - return; - } - if ($vtype eq 'images') { + my $vtype_subdir = plugin_get_vtype_subdir($scfg, $vtype); + + # Strip the vtype subdir from beginning of the current path + # so that we don't have to take it into account when parsing the file name + my $filename = $path; + if ($filename !~ s!^\Q$vtype_subdir\E!!) { + return; + } + return if $filename !~ m!/(\d+)/([^/\s]+)$!; my $vmid = $1; my $name = $2; @@ -756,27 +756,7 @@ sub path_to_volume_id { return; } - if ($vtype eq 'iso') { - return parse_path_as_volid($sid, $scfg, $path, $vtype); - } - - if ($vtype eq 'vztmpl') { - return parse_path_as_volid($sid, $scfg, $path, $vtype); - } - - if ($vtype eq 'backup') { - return parse_path_as_volid($sid, $scfg, $path, $vtype); - } - - if ($vtype eq 'snippets') { - return parse_path_as_volid($sid, $scfg, $path, $vtype); - } - - if ($vtype eq 'import') { - return parse_path_as_volid($sid, $scfg, $path, $vtype); - } - - return; + return parse_path_as_volid($sid, $scfg, $path, $vtype); }; my $vtypes_to_check = $get_vtypes_to_check->(); -- 2.47.3