* [pve-devel] [PATCH pve-storage] fix #6450: add file-checksum endpoint to storage API
@ 2025-09-29 9:35 Nicolas Frey
0 siblings, 0 replies; only message in thread
From: Nicolas Frey @ 2025-09-29 9:35 UTC (permalink / raw)
To: 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 <n.frey@proxmox.com>
---
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-29 9:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-29 9:35 [pve-devel] [PATCH pve-storage] fix #6450: add file-checksum endpoint to storage API Nicolas Frey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox