Commit c202f96a authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add image hash support.

parent d85560a6
......@@ -135,6 +135,7 @@ sub updated($) { return field($_[0], "updated"); }
sub mbr_version($) { return field($_[0], "mbr_version"); }
sub access_key($) { return field($_[0], "access_key"); }
sub uuid($) { return field($_[0], "uuid"); }
sub hash($) { return field($_[0], "hash"); }
#
# Get a list of all running frisbee images.
......@@ -277,7 +278,9 @@ sub Create($$$$$$$$)
$query .= ",gid='$gid',gid_idx='$gid_idx'";
$query .= ",creator='$uid',creator_idx='$uid_idx'";
$query .= ",created=now()";
$query .= ",description=$desc";
$query .= ",description=$desc";
$query .= ",hash=" . DBQuoteSpecial($argref->{'hash'})
if (exists($argref->{'hash'}));
if (! DBQueryWarn($query)) {
DBQueryWarn("unlock tables");
......@@ -357,7 +360,7 @@ sub EditImageid($$$$)
# (Others above already did their own updates.)
#
my %updates;
foreach my $col ("description", "path", "mbr_version") {
foreach my $col ("description", "path", "mbr_version", "hash") {
# Copy args we want so that others can't get through.
if (exists($argref->{$col})) {
$updates{$col} = $mods{$col} = $argref->{$col};
......@@ -736,6 +739,27 @@ sub MarkUpdateTime($)
return 0;
}
#
# Set the hash.
#
sub SetHash($$)
{
my ($self, $hash) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $imageid = $self->imageid();
my $safe_hash = DBQuoteSpecial($hash);
return -1
if (! DBQueryWarn("update images set hash=$safe_hash " .
"where imageid='$imageid'"));
return 0;
}
#
# Get the type list.
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment