From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 48C481FF15E for ; Mon, 29 Sep 2025 11:35:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 42CE5DD91; Mon, 29 Sep 2025 11:35:58 +0200 (CEST) From: Nicolas Frey To: pve-devel@lists.proxmox.com Date: Mon, 29 Sep 2025 11:35:55 +0200 Message-ID: <20250929093555.86352-1-n.frey@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.175 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH pve-storage] fix #6450: add file-checksum endpoint to storage API X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" The storage API endpoint now supports an optional 'checksum' parameter. If set, the checksum is calculated using one of the hashing algorithms listed in the enum and returned in the 'checksum' return property. Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=6450 Signed-off-by: Nicolas Frey --- src/PVE/API2/Storage/Content.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/PVE/API2/Storage/Content.pm b/src/PVE/API2/Storage/Content.pm index 1fe7303..ea60589 100644 --- a/src/PVE/API2/Storage/Content.pm +++ b/src/PVE/API2/Storage/Content.pm @@ -306,6 +306,12 @@ __PACKAGE__->register_method({ description => "Volume identifier", type => 'string', }, + checksum => { + description => 'The algorithm to calculate the checksum of the file.', + enum => [qw(sha512 sha384 sha256 sha224 sha1 md5)], + type => 'string', + optional => 1, + } }, }, returns => { @@ -340,6 +346,11 @@ __PACKAGE__->register_method({ type => 'boolean', optional => 1, }, + checksum => { + description => 'The checksum of the file.', + type => 'string', + optional => 1, + } }, }, code => sub { @@ -376,6 +387,11 @@ __PACKAGE__->register_method({ warn $@ if $@; } + if (exists $param->{checksum}) { + print "calculating checksum...\n"; + $entry->{checksum} = PVE::Tools::get_file_hash($param->{checksum}, $path); + } + return $entry; }, }); -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel