From 127a89a059138463508d8c1d7d4cc8101f88f5d5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Feb 2010 08:59:52 -0600 Subject: [PATCH] Import version as of 2010-02-22 for upload-ftp-v1.1.pl --- upload-ftp-v1.1.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/upload-ftp-v1.1.pl b/upload-ftp-v1.1.pl index 3360ddb..4bdca33 100755 --- a/upload-ftp-v1.1.pl +++ b/upload-ftp-v1.1.pl @@ -209,7 +209,8 @@ sub main } } }; - + ftp_warn ("eval failed: $@") if $@; + # clean up files if we abort while processing a triplet cleanup ($files->{"sig"}, $files->{"upload"}, $files->{"directive"}) if ($@); # clear out the current package that we just finished processing @@ -308,12 +309,17 @@ sub execute_commands { chomp($cwd); # change to destination dir chdir($destdir); + # if the symlink already exists, remove it + if (-l $info{$key}{link}) { + unlink($info{$key}{link}) || &fatal("removal of symlink $info{$key}{link} failed: $!",1); + } # symlink away! - symlink("$target",$info{$key}{link}) || &fatal("creation of symlink $info{$key}{link} to $1 in $destdir failed: $!",1); + symlink("$target",$info{$key}{link}) || &fatal("creation of symlink $info{$key}{link} to $target in $destdir failed: $!",1); # go back to current working dir - ftp_syslog('info', "($log_style) added symlink $destdir/" . $info{$key}{link} . " pointing to $destdir/$1"); + ftp_syslog('info', "($log_style) added symlink $destdir/" . $info{$key}{link} . " pointing to $destdir/$target"); chdir($cwd) || &fatal("chdir to $cwd failed: $!",1); } elsif ($key =~ /^rmsymlink-(.*)/) { + &fatal("refusing to remove a non-symlink file",1) unless -l "$destdir/$1"; unlink("$destdir/$1") || &fatal("removal of symlink $1 failed: $!",1); ftp_syslog('info', "($log_style) removed symlink $destdir/$1"); } elsif ($key =~ /^archive-(.*)/) { -- 2.25.1