From 9626b8c731d43802fb69902b742f63d173d69aea Mon Sep 17 00:00:00 2001 From: Marcelo Leitner Date: Thu, 14 Jun 2007 18:23:13 +0000 Subject: - As this action is unique, avoid too much flexibility and simplify the code. - Use . for hidding temporary files instead of .new suffix. --- lib/Youri/Submit/Action/Sendcache.pm | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/Youri/Submit/Action/Sendcache.pm b/lib/Youri/Submit/Action/Sendcache.pm index 1d52100..8d9cf94 100644 --- a/lib/Youri/Submit/Action/Sendcache.pm +++ b/lib/Youri/Submit/Action/Sendcache.pm @@ -26,13 +26,12 @@ sub _init { ssh_key => '', verbose => '', root => '', - keep_svn_release => '', @_ ); croak "undefined upload host" unless $options{uphost}; croak "undefined ssh key" unless $options{ssh_key}; - foreach my $var ('perms', 'user', 'uphost', 'ssh_key', 'verbose', 'root', 'keep_svn_release') { + foreach my $var ('perms', 'user', 'uphost', 'ssh_key', 'verbose', 'root') { $self->{"_$var"} = $options{$var}; } @@ -48,17 +47,14 @@ sub run { $dest =~ s!$repository->{_upload_root}/$repository->{_queue}!$self->{_root}!; print "Sending file $file to $dest\n" if $self->{_verbose}; - my $base; - if ($self->{_keep_svn_release}) { - $base = basename($file) - } else { - ($base) = $file =~ /.*\/(?:@\d+:)?([^\/]*)/ - } - my $destfile = "$dest$base"; + my $destfile = "$dest".basename($file); $destfile =~ s,/[^/_]+_([^/]+)$,/$1,; + $destfile =~ s,/@\d+:,/,; + my $destfilehidden = $destfile; + $destfilehidden =~ s,/([^/]+)$,/.$1,; - my $cmd = "scp -i $self->{_ssh_key} $file $self->{_user}\@$self->{_uphost}:/$destfile.new"; - my $cmd2 = "ssh -i $self->{_ssh_key} $self->{_user}\@$self->{_uphost} \"mv /$destfile.new /$destfile\""; + my $cmd = "scp -i $self->{_ssh_key} $file $self->{_user}\@$self->{_uphost}:/$destfilehidden"; + my $cmd2 = "ssh -i $self->{_ssh_key} $self->{_user}\@$self->{_uphost} \"mv /$destfilehidden /$destfile\""; print "Submit::Action::Send: doing $cmd\n$cmd2\n" if 1 || $self->{_verbose}; if (!$self->{_test}) { if (!system($cmd)) { -- cgit v1.2.1