]> iEval git - gruntmaster-page.git/commitdiff
Fix file uploads
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 4 Jan 2015 13:48:26 +0000 (15:48 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 4 Jan 2015 13:48:26 +0000 (15:48 +0200)
lib/Plack/App/Gruntmaster.pm

index 14e79871b5e2e8e32c9ccce9fbe79bb841b59002..da00862dfa48a6579aa092687c2785769f877757 100644 (file)
@@ -199,16 +199,17 @@ sub dispatch_request{
                        reply 'Password changed successfully';
                },
 
-               sub (/action/submit + %:problem=&:contest~&:prog_format=&:source_code~ + *:prog~) {
+               sub (/action/submit + %:problem=&:contest~&:prog_format=&:source_code~ + *prog~) {
+                       my (undef, undef, $prog) = @_;
                        forbid !remote_user;
                        return reply 'This contest has finished' if contest && contest->is_finished;
                        return reply 'This contest has not yet started' if !admin && contest && contest->is_pending;
-                       return reply 'Maximum source size is 10KB' if ($_{prog} ? $_{prog}->size : length $_{source_code}) > 10 * 1024;
+                       return reply 'Maximum source size is 10KB' if ($prog ? $prog->size : length $_{source_code}) > 10 * 1024;
                        return reply 'You must wait 30 seconds between jobs' if !admin && time <= remote_user->lastjob + 30;
                        remote_user->update({lastjob => time});
 
-                       my $prog = $_{prog} ? read_file $_{prog}->path : $_{source_code};
-                       unlink $_{prog}->path if $_{prog};
+                       my $source = $prog ? read_file $prog->path : $_{source_code};
+                       unlink $prog->path if $prog;
                        db->jobs->create({
                                maybe contest => $_{contest},
                                maybe private => problem->private,
@@ -216,7 +217,7 @@ sub dispatch_request{
                                extension => FORMAT_EXTENSION->{$_{prog_format}},
                                format => $_{prog_format},
                                problem => $_{problem},
-                               source => $prog,
+                               source => $source,
                                owner => remote_user->id,
                        });
 
This page took 0.026996 seconds and 4 git commands to generate.