From 2579f964830eb6936d30cf913e59a9dcfad774a9 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 12 Dec 2022 13:05:00 +0100 Subject: [PATCH] backup restore: code style cleanup 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 --- src/PMG/Backup.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm index e6994c9..e87cc42 100644 --- a/src/PMG/Backup.pm +++ b/src/PMG/Backup.pm @@ -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 || -- 2.39.5