Commit 8fe6bc5c by Vicent Marti

odb: Refresh on `exists` query too

parent 891a4681
...@@ -529,6 +529,7 @@ int git_odb_exists(git_odb *db, const git_oid *id) ...@@ -529,6 +529,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
git_odb_object *object; git_odb_object *object;
unsigned int i; unsigned int i;
bool found = false; bool found = false;
bool refreshed = false;
assert(db && id); assert(db && id);
...@@ -537,6 +538,7 @@ int git_odb_exists(git_odb *db, const git_oid *id) ...@@ -537,6 +538,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
return (int)true; return (int)true;
} }
attempt_lookup:
for (i = 0; i < db->backends.length && !found; ++i) { for (i = 0; i < db->backends.length && !found; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i); backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend; git_odb_backend *b = internal->backend;
...@@ -545,6 +547,16 @@ int git_odb_exists(git_odb *db, const git_oid *id) ...@@ -545,6 +547,16 @@ int git_odb_exists(git_odb *db, const git_oid *id)
found = b->exists(b, id); found = b->exists(b, id);
} }
if (!found && !refreshed) {
if (git_odb_refresh(db) < 0) {
giterr_clear();
return (int)false;
}
refreshed = true;
goto attempt_lookup;
}
return (int)found; return (int)found;
} }
...@@ -674,7 +686,6 @@ int git_odb_read_prefix( ...@@ -674,7 +686,6 @@ int git_odb_read_prefix(
} }
attempt_lookup: attempt_lookup:
for (i = 0; i < db->backends.length; ++i) { for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i); backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend; git_odb_backend *b = internal->backend;
......
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