From f9997b5dece4e8d819c83c93c3d1f5f01e367a06 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 5 Nov 2022 16:14:16 -0500 Subject: [PATCH] Use structured exceptions in execute_commands --- gatekeeper.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 9f453f4..5f54ca2 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -2491,21 +2491,25 @@ sub execute_commands { # if the symlink already exists, remove it if (-l $abslinkname) { unlink $abslinkname - or fatal("removal of symlink $linkname failed: $!",1); + or throw processing_error => command => $step, + summary => "removal of symlink $linkname failed: $!"; } # symlink away! symlink $target, $abslinkname - or fatal("creation of symlink $linkname " - ."to $target in $header->{directory} failed: $!",1); + or throw processing_error => command => $step, + summary => "creation of symlink $linkname " + ."to $target in $header->{directory} failed: $!"; ftp_syslog('info', "added symlink $linkname pointing to " ."$target in $header->{directory}"); } elsif ($step->[0] eq 'rmsymlink') { my $abslinkname = File::Spec->catfile($Public_dir, @directory, $step->[1]); - fatal("refusing to remove a non-symlink file",1) - unless -l $abslinkname; + throw processing_error => command => $step, + summary => "refusing to remove a non-symlink file" + unless -l $abslinkname; unlink $abslinkname - or fatal("removal of symlink $step->[1] failed: $!",1); + or throw processing_error => command => $step, + summary => "removal of symlink $step->[1] failed: $!"; ftp_syslog('info', "removed symlink $step->[1] in $header->{directory}"); } elsif ($step->[0] eq 'archive') { # We now also allow archiving entire directories -- 2.25.1