mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 21:57:36 +00:00
cache sync: move stat initialization to main unpack
This commit is contained in:
parent
cb98cb838d
commit
795cdfc9ab
3 changed files with 16 additions and 5 deletions
|
@ -19,11 +19,8 @@ cache_sync_init(HashIndex *chunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
unpack_init(&ctx->ctx);
|
unpack_init(&ctx->ctx);
|
||||||
|
/* needs to be set only once */
|
||||||
ctx->ctx.user.chunks = chunks;
|
ctx->ctx.user.chunks = chunks;
|
||||||
ctx->ctx.user.last_error = NULL;
|
|
||||||
ctx->ctx.user.level = 0;
|
|
||||||
ctx->ctx.user.inside_chunks = false;
|
|
||||||
ctx->buf = NULL;
|
ctx->buf = NULL;
|
||||||
ctx->head = 0;
|
ctx->head = 0;
|
||||||
ctx->tail = 0;
|
ctx->tail = 0;
|
||||||
|
|
|
@ -89,6 +89,8 @@ typedef struct unpack_user {
|
||||||
expect_csize,
|
expect_csize,
|
||||||
/* next thing must be the end of the CLE (array_end) */
|
/* next thing must be the end of the CLE (array_end) */
|
||||||
expect_entry_end,
|
expect_entry_end,
|
||||||
|
|
||||||
|
expect_item_begin
|
||||||
} expect;
|
} expect;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -108,6 +110,14 @@ typedef int (*execute_fn)(unpack_context *ctx, const char* data, size_t len, siz
|
||||||
return -1; \
|
return -1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void unpack_init_user_state(unpack_user *u)
|
||||||
|
{
|
||||||
|
u->last_error = NULL;
|
||||||
|
u->level = 0;
|
||||||
|
u->inside_chunks = false;
|
||||||
|
u->expect = expect_item_begin;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int unpack_callback_int64(unpack_user* u, int64_t d)
|
static inline int unpack_callback_int64(unpack_user* u, int64_t d)
|
||||||
{
|
{
|
||||||
switch(u->expect) {
|
switch(u->expect) {
|
||||||
|
@ -282,8 +292,11 @@ static inline int unpack_callback_map(unpack_user* u, unsigned int n)
|
||||||
{
|
{
|
||||||
(void)n;
|
(void)n;
|
||||||
|
|
||||||
|
|
||||||
if(u->level == 0) {
|
if(u->level == 0) {
|
||||||
|
if(u->expect != expect_item_begin) {
|
||||||
|
set_last_error("Invalid state transition"); /* unreachable */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/* This begins a new Item */
|
/* This begins a new Item */
|
||||||
u->expect = expect_chunks_map_key;
|
u->expect = expect_chunks_map_key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ static inline void unpack_init(unpack_context* ctx)
|
||||||
ctx->cs = CS_HEADER;
|
ctx->cs = CS_HEADER;
|
||||||
ctx->trail = 0;
|
ctx->trail = 0;
|
||||||
ctx->top = 0;
|
ctx->top = 0;
|
||||||
|
unpack_init_user_state(&ctx->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define construct 1
|
#define construct 1
|
||||||
|
|
Loading…
Reference in a new issue