feature #336: Preserve SOURCE if present in the template file

This commit is contained in:
Ruben S. Montero committed 2010-09-08 13:27:00 +02:00
1 parent 05032061c9
commit 3e8db30a9d
1 file changed
+11 -7
+11 -7
View File
@@ -156,9 +156,6 @@ int Image::insert(SqlDB *db, string& error_str)
string persistent_attr;
string dev_prefix;
ostringstream tmp_hashstream;
ostringstream tmp_sourcestream;
// ---------------------------------------------------------------------
// Check default image attributes
// ---------------------------------------------------------------------
@@ -230,13 +227,20 @@ int Image::insert(SqlDB *db, string& error_str)
// ------------ SOURCE (path to store the image)--------------------
tmp_hashstream << uid << ":" << name;
get_template_attribute("SOURCE", source);
tmp_sourcestream << ImagePool::source_prefix() << "/";
tmp_sourcestream << sha1_digest(tmp_hashstream.str());
if (source.empty())
{
ostringstream tmp_hashstream;
ostringstream tmp_sourcestream;
source = tmp_sourcestream.str();
tmp_hashstream << uid << ":" << name;
tmp_sourcestream << ImagePool::source_prefix() << "/";
tmp_sourcestream << sha1_digest(tmp_hashstream.str());
source = tmp_sourcestream.str();
}
state = DISABLED;