]> mj.ucw.cz Git - moe.git/commitdiff
Keep local history of submissions in ~/.history.
authorMartin Mares <mj@ucw.cz>
Fri, 29 Jun 2007 15:47:30 +0000 (17:47 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 29 Jun 2007 15:47:30 +0000 (17:47 +0200)
TODO
submit/MO/Submit.pm
submit/remote-submit

diff --git a/TODO b/TODO
index e323788593369b8705363076156c6276fa8cec55..35e64c16299d438e8d44537ce2347758a54bc795 100644 (file)
--- a/TODO
+++ b/TODO
@@ -17,7 +17,6 @@ Installer:
 - quotas
 
 New submitter:
-- contest: local history
 - contest: task status cache
 - contest: problems with SIGPIPE
 
index bae8b5f34ab1150a702360a66ff1ed0324794564..554fda83c4168f4ceaf19e7b16b577b383b69e28 100644 (file)
@@ -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;
index ef30ccb73f1842ac1fbbb5ef1d28a5e2228bf376..c2e13a0b06bddcb068b4f65496babd983ead0626 100755 (executable)
@@ -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($) {