mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
Merge pull request #1294 from enkore/f/hashindex-rc
Fix missing return code check in ChunkIndex._add
This commit is contained in:
commit
c16334981a
2 changed files with 9 additions and 4 deletions
|
@ -100,6 +100,8 @@ static int hashindex_delete(HashIndex *index, const void *key);
|
|||
static void *hashindex_next_key(HashIndex *index, const void *key);
|
||||
|
||||
/* Private API */
|
||||
static void hashindex_free(HashIndex *index);
|
||||
|
||||
static int
|
||||
hashindex_index(HashIndex *index, const void *key)
|
||||
{
|
||||
|
@ -148,7 +150,11 @@ hashindex_resize(HashIndex *index, int capacity)
|
|||
return 0;
|
||||
}
|
||||
while((key = hashindex_next_key(index, key))) {
|
||||
hashindex_set(new, key, key + key_size);
|
||||
if(!hashindex_set(new, key, key + key_size)) {
|
||||
/* This can only happen if there's a bug in the code calculating capacity */
|
||||
hashindex_free(new);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
free(index->buckets);
|
||||
index->buckets = new->buckets;
|
||||
|
|
|
@ -14,8 +14,6 @@ cdef extern from "_hashindex.c":
|
|||
HashIndex *hashindex_read(char *path)
|
||||
HashIndex *hashindex_init(int capacity, int key_size, int value_size)
|
||||
void hashindex_free(HashIndex *index)
|
||||
void hashindex_merge(HashIndex *index, HashIndex *other)
|
||||
void hashindex_add(HashIndex *index, void *key, void *value)
|
||||
int hashindex_get_size(HashIndex *index)
|
||||
int hashindex_write(HashIndex *index, char *path)
|
||||
void *hashindex_get(HashIndex *index, void *key)
|
||||
|
@ -310,7 +308,8 @@ cdef class ChunkIndex(IndexBase):
|
|||
result64 = refcount1 + refcount2
|
||||
values[0] = _htole32(min(result64, _MAX_VALUE))
|
||||
else:
|
||||
hashindex_set(self.index, key, data)
|
||||
if not hashindex_set(self.index, key, data):
|
||||
raise Exception('hashindex_set failed')
|
||||
|
||||
def merge(self, ChunkIndex other):
|
||||
cdef void *key = NULL
|
||||
|
|
Loading…
Reference in a new issue