mirror of
https://github.com/simon987/sist2.git
synced 2025-04-10 14:06:45 +00:00
progress bar fix
This commit is contained in:
parent
c3b7a05dde
commit
bfc7f4ddb6
@ -85,7 +85,7 @@ include_directories(
|
||||
target_compile_options(sist2
|
||||
PRIVATE
|
||||
-O3
|
||||
-march=native
|
||||
# -march=native
|
||||
-fno-stack-protector
|
||||
-fomit-frame-pointer
|
||||
)
|
||||
|
@ -16,8 +16,8 @@ struct {
|
||||
int content_size;
|
||||
float tn_qscale;
|
||||
|
||||
int stat_tn_size;
|
||||
int stat_index_size;
|
||||
size_t stat_tn_size;
|
||||
size_t stat_index_size;
|
||||
|
||||
GHashTable *original_table;
|
||||
GHashTable *copy_table;
|
||||
|
@ -66,7 +66,7 @@ index_descriptor_t read_index_descriptor(char *path) {
|
||||
strcpy(descriptor.root, cJSON_GetObjectItem(json, "root")->valuestring);
|
||||
strcpy(descriptor.name, cJSON_GetObjectItem(json, "name")->valuestring);
|
||||
strcpy(descriptor.rewrite_url, cJSON_GetObjectItem(json, "rewrite_url")->valuestring);
|
||||
descriptor.root_len = (int)strlen(descriptor.root);
|
||||
descriptor.root_len = (short)strlen(descriptor.root);
|
||||
strcpy(descriptor.version, cJSON_GetObjectItem(json, "version")->valuestring);
|
||||
strcpy(descriptor.uuid, cJSON_GetObjectItem(json, "uuid")->valuestring);
|
||||
|
||||
@ -127,8 +127,8 @@ void write_document(document_t *doc) {
|
||||
dyn_buffer_t buf = dyn_buffer_create();
|
||||
|
||||
// Ignore root directory in the file path
|
||||
doc->ext = (short)(doc->ext - ScanCtx.index.desc.root_len);
|
||||
doc->base = (short)(doc->base - ScanCtx.index.desc.root_len);
|
||||
doc->ext = doc->ext - ScanCtx.index.desc.root_len;
|
||||
doc->base = doc->base - ScanCtx.index.desc.root_len;
|
||||
doc->filepath += ScanCtx.index.desc.root_len;
|
||||
|
||||
dyn_buffer_write(&buf, doc, sizeof(line_t));
|
||||
|
@ -20,7 +20,7 @@ parse_job_t *create_parse_job(const char *filepath, const struct stat *info, int
|
||||
return job;
|
||||
}
|
||||
|
||||
int handle_entry(const char *filepath, const struct stat *info, const int typeflag, struct FTW *ftw) {
|
||||
int handle_entry(const char *filepath, const struct stat *info, int typeflag, struct FTW *ftw) {
|
||||
if (typeflag == FTW_F && S_ISREG(info->st_mode)) {
|
||||
parse_job_t *job = create_parse_job(filepath, info, ftw->base);
|
||||
tpool_add_work(ScanCtx.pool, parse, job);
|
||||
|
@ -42,7 +42,8 @@ fz_page *render_cover(fz_context *ctx, document_t *doc, fz_document *fzdoc) {
|
||||
return cover;
|
||||
}
|
||||
|
||||
void fz_noop_callback(void *user, const char *message) {}
|
||||
void fz_noop_callback(__attribute__((unused)) void *user, __attribute__((unused)) const char *message) {}
|
||||
|
||||
|
||||
void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
|
||||
|
||||
@ -85,27 +86,14 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
|
||||
page = fz_load_page(ctx, fzdoc, current_page);
|
||||
}
|
||||
|
||||
fz_stext_page *stext;
|
||||
fz_device *dev = NULL;
|
||||
fz_stext_page *stext = fz_new_stext_page(ctx, fz_bound_page(ctx, page));
|
||||
fz_device *dev = fz_new_stext_device(ctx, stext, &opts);
|
||||
|
||||
fz_var(dev);
|
||||
pthread_mutex_lock(&ScanCtx.mupdf_mu);
|
||||
fz_run_page_contents(ctx, page, dev, fz_identity, NULL);
|
||||
pthread_mutex_unlock(&ScanCtx.mupdf_mu);
|
||||
|
||||
stext = fz_new_stext_page(ctx, fz_bound_page(ctx, page));
|
||||
fz_try(ctx)
|
||||
{
|
||||
dev = fz_new_stext_device(ctx, stext, &opts);
|
||||
pthread_mutex_lock(&ScanCtx.mupdf_mu);
|
||||
fz_run_page_contents(ctx, page, dev, fz_identity, NULL);
|
||||
pthread_mutex_unlock(&ScanCtx.mupdf_mu);
|
||||
fz_close_device(ctx, dev);
|
||||
}
|
||||
fz_always(ctx)
|
||||
fz_drop_device(ctx, dev);
|
||||
fz_catch(ctx)
|
||||
{
|
||||
fz_drop_stext_page(ctx, stext);
|
||||
fz_rethrow(ctx);
|
||||
}
|
||||
fz_drop_device(ctx, dev);
|
||||
|
||||
fz_stext_block *block = stext->first_block;
|
||||
while (block != NULL) {
|
||||
@ -147,6 +135,8 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
|
||||
fz_drop_stream(ctx, stream);
|
||||
fz_drop_document(ctx, fzdoc);
|
||||
fz_drop_context(ctx);
|
||||
} fz_catch(ctx) {}
|
||||
} fz_catch(ctx) {
|
||||
fprintf(stderr, "Error %s %s\n", doc->filepath, ctx->error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ char *expandpath(const char *path) {
|
||||
|
||||
void progress_bar_print(double percentage, size_t tn_size, size_t index_size) {
|
||||
|
||||
static int last_val = 0;
|
||||
static int last_val = -1;
|
||||
int val = (int) (percentage * 100);
|
||||
if (last_val == val || val > 100 || index_size < 1024) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user