Normalize archive progress calculation
This commit is contained in:
parent
dd4bf2c41f
commit
16fffd67ea
|
@ -496,7 +496,6 @@ static bool file_archive_walk(const char *file, const char *valid_exts,
|
||||||
|
|
||||||
int file_archive_parse_file_progress(file_archive_transfer_t *state)
|
int file_archive_parse_file_progress(file_archive_transfer_t *state)
|
||||||
{
|
{
|
||||||
/* FIXME: this estimate is worse than before */
|
|
||||||
ptrdiff_t delta = 0;
|
ptrdiff_t delta = 0;
|
||||||
|
|
||||||
if (!state || state->archive_size == 0)
|
if (!state || state->archive_size == 0)
|
||||||
|
@ -504,7 +503,10 @@ int file_archive_parse_file_progress(file_archive_transfer_t *state)
|
||||||
|
|
||||||
delta = state->directory - state->data;
|
delta = state->directory - state->data;
|
||||||
|
|
||||||
return (int)(delta * 100 / state->archive_size);
|
if (!state->start_delta)
|
||||||
|
state->start_delta = delta;
|
||||||
|
|
||||||
|
return (int)(((delta - state->start_delta) * 100) / (state->archive_size - state->start_delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -240,7 +240,7 @@ static int zip_file_read(
|
||||||
const char *needle, void **buf,
|
const char *needle, void **buf,
|
||||||
const char *optional_outfile)
|
const char *optional_outfile)
|
||||||
{
|
{
|
||||||
file_archive_transfer_t zlib = {ARCHIVE_TRANSFER_NONE, 0, NULL, NULL, NULL, NULL, NULL, NULL };
|
file_archive_transfer_t zlib = {0};
|
||||||
struct archive_extract_userdata userdata = {{0}};
|
struct archive_extract_userdata userdata = {{0}};
|
||||||
bool returnerr = true;
|
bool returnerr = true;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
@ -64,6 +64,7 @@ typedef struct file_archive_transfer
|
||||||
{
|
{
|
||||||
enum file_archive_transfer_type type;
|
enum file_archive_transfer_type type;
|
||||||
int32_t archive_size;
|
int32_t archive_size;
|
||||||
|
ptrdiff_t start_delta;
|
||||||
file_archive_file_data_t *handle;
|
file_archive_file_data_t *handle;
|
||||||
void *stream;
|
void *stream;
|
||||||
const uint8_t *footer;
|
const uint8_t *footer;
|
||||||
|
|
Loading…
Reference in New Issue