Commit 003c1dc4 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Allow lookup of deleted images/osinfos when looking up by numeric id and

version number.
parent 04c35b0b
...@@ -122,7 +122,7 @@ sub Lookup($$;$$) ...@@ -122,7 +122,7 @@ sub Lookup($$;$$)
"left join image_versions as v on ". "left join image_versions as v on ".
" v.imageid=i.imageid ". " v.imageid=i.imageid ".
"where i.pid='$1' and i.imagename='$2' and ". "where i.pid='$1' and i.imagename='$2' and ".
" v.version='$3' and v.deleted is null"); " v.version='$3'");
return undef return undef
if (!$result || !$result->numrows); if (!$result || !$result->numrows);
...@@ -161,13 +161,15 @@ sub Lookup($$;$$) ...@@ -161,13 +161,15 @@ sub Lookup($$;$$)
} }
elsif (!defined($arg3)) { elsif (!defined($arg3)) {
if ($arg1 =~ /^\d+$/ && $arg2 =~ /^\d+$/) { if ($arg1 =~ /^\d+$/ && $arg2 =~ /^\d+$/) {
#
# This will get deleted images, but that is okay.
#
my $result = my $result =
DBQueryWarn("select i.*,v.*,i.uuid as image_uuid ". DBQueryWarn("select i.*,v.*,i.uuid as image_uuid ".
" from images as i ". " from image_versions as v ".
"left join image_versions as v on ". "left join images as i on ".
" v.imageid=i.imageid ". " v.imageid=i.imageid ".
"where i.imageid='$arg1' and v.version='$arg2' ". "where v.imageid='$arg1' and v.version='$arg2'");
" and v.deleted is null");
return undef return undef
if (! $result || !$result->numrows); if (! $result || !$result->numrows);
...@@ -209,7 +211,7 @@ sub Lookup($$;$$) ...@@ -209,7 +211,7 @@ sub Lookup($$;$$)
"left join image_versions as v on ". "left join image_versions as v on ".
" v.imageid=i.imageid ". " v.imageid=i.imageid ".
"where i.pid='$arg1' and i.imagename='$arg2' and ". "where i.pid='$arg1' and i.imagename='$arg2' and ".
" v.version='$arg3' and v.deleted is null"); " v.version='$arg3'");
return undef return undef
if (!$result || !$result->numrows); if (!$result || !$result->numrows);
......
...@@ -184,11 +184,12 @@ sub Lookup($$;$$) ...@@ -184,11 +184,12 @@ sub Lookup($$;$$)
} }
elsif (!defined($arg3)) { elsif (!defined($arg3)) {
if ($arg1 =~ /^\d+$/ && $arg2 =~ /^\d+$/) { if ($arg1 =~ /^\d+$/ && $arg2 =~ /^\d+$/) {
#
# This will get deleted OSs, but that is okay.
#
my $result = my $result =
DBQueryWarn("select v.* from os_info as o ". DBQueryWarn("select v.* from os_info_versions as v ".
"left join os_info_versions as v on ". "where v.osid='$arg1' and v.vers='$arg2'");
" v.osid=o.osid ".
"where o.osid='$arg1' and v.vers='$arg2'");
return undef return undef
if (! $result || !$result->numrows); if (! $result || !$result->numrows);
......
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