all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] applied: [PATCH storage 1/2] api: content/backup: handle deletion of notes
@ 2020-12-07 15:16 Thomas Lamprecht
  2020-12-07 15:16 ` [pve-devel] applied: [PATCH storage 2/2] nfs and cifs: implement backup notes helper Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Lamprecht @ 2020-12-07 15:16 UTC (permalink / raw)
  To: pve-devel

Previous to this we did not called the plugins update_volume_notes at
all in the case where a user delted the textarea, which results to
passing a falsy value ('').

Also adapt the currently sole implementation to delete the notes field
in the undef or '' value case. This can be done safely, as we default
to returning an empty string if no notes file exists.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 PVE/API2/Storage/Content.pm | 4 ++--
 PVE/Storage/DirPlugin.pm    | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Storage/Content.pm b/PVE/API2/Storage/Content.pm
index 349231d..c391b35 100644
--- a/PVE/API2/Storage/Content.pm
+++ b/PVE/API2/Storage/Content.pm
@@ -370,8 +370,8 @@ __PACKAGE__->register_method ({
 
 	PVE::Storage::check_volume_access($rpcenv, $authuser, $cfg, undef, $volid);
 
-	if (my $notes = $param->{notes}) {
-	    PVE::Storage::update_volume_notes($cfg, $volid, $notes);
+	if (exists $param->{notes}) {
+	    PVE::Storage::update_volume_notes($cfg, $volid, $param->{notes});
 	}
 
 	return undef;
diff --git a/PVE/Storage/DirPlugin.pm b/PVE/Storage/DirPlugin.pm
index 7bb85e8..2267f11 100644
--- a/PVE/Storage/DirPlugin.pm
+++ b/PVE/Storage/DirPlugin.pm
@@ -107,8 +107,11 @@ sub update_volume_notes {
     my $path = $class->filesystem_path($scfg, $volname);
     $path .= $class->SUPER::NOTES_EXT;
 
-    PVE::Tools::file_set_contents($path, $notes);
-
+    if (defined($notes) && $notes ne '') {
+	PVE::Tools::file_set_contents($path, $notes);
+    } else {
+	unlink $path or die "could not delete notes - $!\n";
+    }
     return;
 }
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH storage 2/2] nfs and cifs: implement backup notes helper
  2020-12-07 15:16 [pve-devel] applied: [PATCH storage 1/2] api: content/backup: handle deletion of notes Thomas Lamprecht
@ 2020-12-07 15:16 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2020-12-07 15:16 UTC (permalink / raw)
  To: pve-devel

reuse the one from DirPlugin by directing the call to it, but with
the actual $class. This should stay stable, as we provide an ABI and
try to always use $class->helpers.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 PVE/Storage/CIFSPlugin.pm | 9 +++++++++
 PVE/Storage/NFSPlugin.pm  | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/PVE/Storage/CIFSPlugin.pm b/PVE/Storage/CIFSPlugin.pm
index 36339db..be06cc7 100644
--- a/PVE/Storage/CIFSPlugin.pm
+++ b/PVE/Storage/CIFSPlugin.pm
@@ -284,4 +284,13 @@ sub check_connection {
     return 1;
 }
 
+sub get_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::get_volume_notes($class, @_);
+}
+sub update_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::update_volume_notes($class, @_);
+}
+
 1;
diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm
index f8d7e68..e8e27c0 100644
--- a/PVE/Storage/NFSPlugin.pm
+++ b/PVE/Storage/NFSPlugin.pm
@@ -171,4 +171,13 @@ sub check_connection {
     return 1;
 }
 
+sub get_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::get_volume_notes($class, @_);
+}
+sub update_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::update_volume_notes($class, @_);
+}
+
 1;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-07 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 15:16 [pve-devel] applied: [PATCH storage 1/2] api: content/backup: handle deletion of notes Thomas Lamprecht
2020-12-07 15:16 ` [pve-devel] applied: [PATCH storage 2/2] nfs and cifs: implement backup notes helper Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal