]> git.proxmox.com Git - pmg-api.git/commitdiff
backup restore: code style cleanup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 12 Dec 2022 12:05:00 +0000 (13:05 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 12 Dec 2022 12:05:05 +0000 (13:05 +0100)
find also takes a code ref directly, and the "wanted" name is a bit
non-ideal anyway, as it has no control over what find "wants" (i.e.,
descends into), but its return value is completely ignored.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/Backup.pm

index e6994c957ce7c7e65e755d9db28a982423312d64..e87cc42a11907d4b93c9274737af9cbdcf04bbcd 100644 (file)
@@ -308,11 +308,14 @@ sub pmg_restore {
            rmtree "$dirname/config/etc/pmg/master";
 
            # remove current config, but keep directories for INotify
-           File::Find::find({ wanted => sub {
-               if ( ! -d $File::Find::name) {
-                   unlink($File::Find::name) || die "removing $File::Find::name failed: $!\n";
-               }
-           }}, '/etc/pmg');
+           File::Find::find(
+               sub {
+                   my $file = $File::Find::name;
+                   return if -d $file;
+                   unlink($file) || die "removing $file failed: $!\n";
+               },
+               '/etc/pmg',
+           );
 
            # copy files
            system("cp -a $dirname/config/etc/pmg/* /etc/pmg/") == 0 ||