Skip to content

Commit

Permalink
Compute hashes of executable files when migrating
Browse files Browse the repository at this point in the history
The 'hash' column was added in commit bc1608f (Add hash to
executable files and immutable executables., 2021-03-30), but the
hashes were not computed for existing files, which broke migrations
from < 8.0.0 (judging fails with error message "Fetching executable
failed for compile script '<n>': Unexpected hash ...").

This commit fixes Version20210407120356.php so that it will compute
the hashes.

Note that this will not fix databases that have already been migrated
from 7.x using a DOMjudge version in the range 8.0.0 to 8.3.0. The
recommended workaround is to upgrade directly from 7.x to 8.3.1 (or
higher). Alternatively, there is a patch[1] that can be used to fix
such databases (it applies to 8.3.0, but the code can be adapted for
8.0).

[1] DOMjudge@f62d0ec
  • Loading branch information
tom93 committed Jul 30, 2024
1 parent 2c1a834 commit defbbfa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions webapp/migrations/Version20210407120356.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function up(Schema $schema) : void
$executableBit = '0';
}
$this->connection->executeStatement(
'INSERT INTO executable_file (`immutable_execid`, `filename`, `ranknumber`, `file_content`, `is_executable`) VALUES (?, ?, ?, ?, ?)',
[$immutable_execid, $filename, $idx, $content, $executableBit]
'INSERT INTO executable_file (`immutable_execid`, `filename`, `ranknumber`, `file_content`, `hash`, `is_executable`) VALUES (?, ?, ?, ?, ?)',
[$immutable_execid, $filename, $idx, $content, $md5($content), $executableBit]
);
}

Expand Down

0 comments on commit defbbfa

Please sign in to comment.