From 4d52eeffe7f6bcf2bcd16f073aed7aca1ae968a5 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 29 Jun 2007 17:47:30 +0200 Subject: [PATCH] Keep local history of submissions in ~/.history. --- TODO | 1 - submit/MO/Submit.pm | 16 +++++++++++----- submit/remote-submit | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index e323788..35e64c1 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,6 @@ Installer: - quotas New submitter: -- contest: local history - contest: task status cache - contest: problems with SIGPIPE diff --git a/submit/MO/Submit.pm b/submit/MO/Submit.pm index bae8b5f..554fda8 100644 --- a/submit/MO/Submit.pm +++ b/submit/MO/Submit.pm @@ -23,9 +23,9 @@ sub new($) { "Cert" => "$mo/cert.pem", "CACert" => "$mo/ca-cert.pem", "Trace" => defined $ENV{"MO_SUBMIT_TRACE"}, - "Checks" => 1, - "AllowOverride" => 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, @@ -169,11 +169,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; diff --git a/submit/remote-submit b/submit/remote-submit index ef30ccb..c2e13a0 100755 --- a/submit/remote-submit +++ b/submit/remote-submit @@ -28,6 +28,10 @@ my $s = stat(*F) or die; my $size = $s->size; my $conn = new MO::Submit; + +my $he = $conn->write_history($task, $part, $ext, $file); +if (defined $he) { die "$he\n"; } + $conn->connect or die $conn->{"error"} . "\n"; sub or_die($) { -- 2.39.2