[pve-devel] [PATCH pve-cluster 2/3] cluster fs: allow to specify file encoding for cfs_write_file

Lukas Wagner l.wagner at proxmox.com
Wed Aug 30 14:37:53 CEST 2023


Since this function is used to store utf8-encoded strings that come
from Rust, we need to be able to save the file in proper utf8 encoding
as well.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 src/PVE/Cluster.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Cluster.pm b/src/PVE/Cluster.pm
index e3705b6..9fdc23d 100644
--- a/src/PVE/Cluster.pm
+++ b/src/PVE/Cluster.pm
@@ -578,7 +578,7 @@ sub cfs_read_file {
 }
 
 sub cfs_write_file {
-    my ($filename, $data) = @_;
+    my ($filename, $data, $encoding) = @_;
 
     my ($version, $info) = cfs_file_version($filename);
 
@@ -592,7 +592,7 @@ sub cfs_write_file {
 	$ci->{version} = undef;
     }
 
-    PVE::Tools::file_set_contents($fsname, $raw);
+    PVE::Tools::file_set_contents($fsname, $raw, undef, $encoding);
 }
 
 my $cfs_lock = sub {
-- 
2.39.2






More information about the pve-devel mailing list