Remove SHA-1 hash from BuildProducts

SHA-1 is deprecated and it will be expensive to compute with the
streaming NAR handler.
This commit is contained in:
Eelco Dolstra
2020-07-27 18:24:10 +02:00
parent 7622cbfe37
commit d4e4be4fd1
11 changed files with 11 additions and 31 deletions

View File

@ -78,7 +78,6 @@ BuildOutput getBuildOutput(nix::ref<Store> store,
product.isRegular = true;
product.fileSize = st.fileSize;
auto contents = accessor->readFile(product.path);
product.sha1hash = hashString(htSHA1, contents);
product.sha256hash = hashString(htSHA256, contents);
}

View File

@ -11,7 +11,7 @@ struct BuildProduct
nix::Path path, defaultPath;
std::string type, subtype, name;
bool isRegular = false;
nix::Hash sha1hash, sha256hash;
nix::Hash sha256hash;
off_t fileSize = 0;
BuildProduct() { }
};

View File

@ -414,13 +414,12 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
unsigned int productNr = 1;
for (auto & product : res.products) {
txn.exec_params0
("insert into BuildProducts (build, productnr, type, subtype, fileSize, sha1hash, sha256hash, path, name, defaultPath) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
("insert into BuildProducts (build, productnr, type, subtype, fileSize, sha256hash, path, name, defaultPath) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
build->id,
productNr++,
product.type,
product.subtype,
product.isRegular ? std::make_optional(product.fileSize) : std::nullopt,
product.isRegular ? std::make_optional(product.sha1hash.to_string(Base16, false)) : std::nullopt,
product.isRegular ? std::make_optional(product.sha256hash.to_string(Base16, false)) : std::nullopt,
product.path,
product.name,

View File

@ -632,7 +632,7 @@ BuildOutput State::getBuildOutputCached(Connection & conn, nix::ref<nix::Store>
res.size = r[0][4].is_null() ? 0 : r[0][4].as<unsigned long long>();
auto products = txn.exec_params
("select type, subtype, fileSize, sha1hash, sha256hash, path, name, defaultPath from BuildProducts where build = $1 order by productnr",
("select type, subtype, fileSize, sha256hash, path, name, defaultPath from BuildProducts where build = $1 order by productnr",
id);
for (auto row : products) {
@ -646,14 +646,12 @@ BuildOutput State::getBuildOutputCached(Connection & conn, nix::ref<nix::Store>
product.fileSize = row[2].as<off_t>();
}
if (!row[3].is_null())
product.sha1hash = Hash(row[3].as<std::string>(), htSHA1);
product.sha256hash = Hash(row[3].as<std::string>(), htSHA256);
if (!row[4].is_null())
product.sha256hash = Hash(row[4].as<std::string>(), htSHA256);
if (!row[5].is_null())
product.path = row[5].as<std::string>();
product.name = row[6].as<std::string>();
if (!row[7].is_null())
product.defaultPath = row[7].as<std::string>();
product.path = row[4].as<std::string>();
product.name = row[5].as<std::string>();
if (!row[6].is_null())
product.defaultPath = row[6].as<std::string>();
res.products.emplace_back(product);
}