forked from lix-project/lix
* I forgot to catch SQLiteBusy in registerValidPaths(). So
registerValidPaths() now handles busy errors and registerValidPath() is simply a wrapper around it.
This commit is contained in:
parent
d787285af9
commit
3dd02580e3
|
@ -463,7 +463,7 @@ unsigned long long LocalStore::addValidPath(const ValidPathInfo & info)
|
|||
SQLiteStmtUse use(stmtRegisterValidPath);
|
||||
stmtRegisterValidPath.bind(info.path);
|
||||
stmtRegisterValidPath.bind("sha256:" + printHash(info.hash));
|
||||
stmtRegisterValidPath.bind(info.registrationTime);
|
||||
stmtRegisterValidPath.bind(info.registrationTime == 0 ? time(0) : info.registrationTime);
|
||||
if (info.deriver != "")
|
||||
stmtRegisterValidPath.bind(info.deriver);
|
||||
else
|
||||
|
@ -506,31 +506,6 @@ void LocalStore::addReference(unsigned long long referrer, unsigned long long re
|
|||
}
|
||||
|
||||
|
||||
void LocalStore::registerValidPath(const ValidPathInfo & info)
|
||||
{
|
||||
assert(info.hash.type == htSHA256);
|
||||
ValidPathInfo info2(info);
|
||||
if (info2.registrationTime == 0) info2.registrationTime = time(0);
|
||||
|
||||
while (1) {
|
||||
try {
|
||||
SQLiteTxn txn(db);
|
||||
|
||||
unsigned long long id = addValidPath(info2);
|
||||
|
||||
foreach (PathSet::const_iterator, i, info2.references)
|
||||
addReference(id, queryValidPathId(*i));
|
||||
|
||||
txn.commit();
|
||||
break;
|
||||
} catch (SQLiteBusy & e) {
|
||||
/* Retry; the `txn' destructor will roll back the current
|
||||
transaction. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LocalStore::registerFailedPath(const Path & path)
|
||||
{
|
||||
if (hasPathFailed(path)) return;
|
||||
|
@ -896,14 +871,26 @@ Hash LocalStore::queryPathHash(const Path & path)
|
|||
}
|
||||
|
||||
|
||||
void LocalStore::registerValidPath(const ValidPathInfo & info)
|
||||
{
|
||||
ValidPathInfos infos;
|
||||
infos.push_back(info);
|
||||
registerValidPaths(infos);
|
||||
}
|
||||
|
||||
|
||||
void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
||||
{
|
||||
while (1) {
|
||||
try {
|
||||
SQLiteTxn txn(db);
|
||||
|
||||
foreach (ValidPathInfos::const_iterator, i, infos)
|
||||
foreach (ValidPathInfos::const_iterator, i, infos) {
|
||||
assert(i->hash.type == htSHA256);
|
||||
/* !!! Maybe the registration info should be updated if the
|
||||
path is already valid. */
|
||||
if (!isValidPath(i->path)) addValidPath(*i);
|
||||
}
|
||||
|
||||
foreach (ValidPathInfos::const_iterator, i, infos) {
|
||||
unsigned long long referrer = queryValidPathId(i->path);
|
||||
|
@ -912,6 +899,12 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
|||
}
|
||||
|
||||
txn.commit();
|
||||
break;
|
||||
} catch (SQLiteBusy & e) {
|
||||
/* Retry; the `txn' destructor will roll back the current
|
||||
transaction. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue