X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=submit%2FMO%2FSubmit.pm;h=0aa165dfa84b9cac3740ad3f57becca5a49ad7e1;hb=663f4a77546b5fc05f9f5dc7b0e5681fb259d9b7;hp=e571be3706ca8ee8f39c4faec7f25ae63bbbccc7;hpb=babd817998d5e7026a3e392024779216ab59ca94;p=eval.git diff --git a/submit/MO/Submit.pm b/submit/MO/Submit.pm index e571be3..0aa165d 100644 --- a/submit/MO/Submit.pm +++ b/submit/MO/Submit.pm @@ -23,8 +23,9 @@ sub new($) { "Cert" => "$mo/cert.pem", "CACert" => "$mo/ca-cert.pem", "Trace" => defined $ENV{"MO_SUBMIT_TRACE"}, - "Checks" => 1, -# "History" => "$home/.history", # Keep submission history in this directory + "Checks" => 1, # Run `check' before submitting + "AllowOverride" => 1, # Allow overriding a failed check + "History" => "$home/.history", # Keep submission history in this directory "RefreshTimer" => 60000, # How often GUI sends STATUS commands [ms] "root" => $root, "user" => $user, @@ -125,7 +126,7 @@ sub connect($) { sub request($$) { my ($self, $obj) = @_; my $sk = $self->{"sk"}; - ## $SIG{'PIPE'} = 'ignore'; + local $SIG{'PIPE'} = 'ignore'; $obj->write($sk); print $sk "\n"; $sk->flush(); @@ -151,6 +152,7 @@ sub reply($) { sub send_file($$$) { my ($self, $fh, $size) = @_; my $sk = $self->{"sk"}; + local $SIG{'PIPE'} = 'ignore'; while ($size) { my $l = ($size < 4096 ? $size : 4096); my $buf = ""; @@ -168,11 +170,17 @@ sub send_file($$$) { return $self->reply; } -sub local_submit($$$$$) { +sub write_history($$$$$) { my ($self, $task, $part, $ext, $filename) = @_; my $hist = $self->{"History"}; -d $hist or mkdir $hist or return "Unable to create $hist: $!"; - ### FIXME: Unfinished + my $now = POSIX::strftime("%H:%M:%S", localtime(time)); + my $maybe_part = ($part eq $task) ? "" : ":$part"; + my $name = "$hist/$now-$task$maybe_part.$ext"; + $self->log("Backing up to $name"); + `cp "$filename" "$name"`; + return "Unable to back up $filename as $name" if $?; + return undef; } 1;