From a664aa0c0dbacdfdb1d5b252d46fff7fc9349d6a Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Thu, 4 Feb 2021 11:36:13 +0100 Subject: [PATCH] QUEUE & MOD: Now the update total count includes the number of favorites in each lists & less verbose queue --- inc/lektor/queue.h | 12 ------------ src/module/module_repo.c | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/inc/lektor/queue.h b/inc/lektor/queue.h index 88a7fe7d..9e063413 100644 --- a/inc/lektor/queue.h +++ b/inc/lektor/queue.h @@ -132,11 +132,6 @@ lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr) if (! (_type & queue->available)) LOG_WARN("QUEUE", "The event %d is not available, push it anyway", _type); - else if (_attr) { - LOG_DEBUG("QUEUE", "Pushed event %d with attr (int: %d, ptr %0*p)", - evt.type, evt.attr, sizeof(size_t) * CHAR_BIT / 4, evt.attr); - } else - LOG_DEBUG("QUEUE", "Pushed event %d with NULL attr", evt.type); end: pthread_mutex_unlock(&queue->lock); } @@ -159,13 +154,6 @@ lkt_queue_handle(struct queue *queue) queue->last -= 1; end: pthread_mutex_unlock(&queue->lock); - if (ret.attr) { - LOG_DEBUG("QUEUE", "Handle event %d with attr (int: %d, ptr: %0*p)", - ret.type, ret.attr, sizeof(size_t) * CHAR_BIT / 4, ret.attr); - } else if (ret.type) { - /* Don't do anyhting with the 'null' event */ - LOG_DEBUG("QUEUE", "Handle event %d with NULL attr", ret.type); - } return ret; } diff --git a/src/module/module_repo.c b/src/module/module_repo.c index 81bf1692..d05c07a1 100644 --- a/src/module/module_repo.c +++ b/src/module/module_repo.c @@ -562,6 +562,7 @@ __handle_fav_list_internal(const char UNUSED *key, const char *val, int UNUSED c struct __uri *uri = (struct __uri *) user; uri->uri.id = strtol(val, NULL, 0); + lkt_queue_send(uri->repo->queue, lkt_event_db_update_tick, NULL); if (!database_plt_add_uri(uri->repo->db, uri->fav, &uri->uri)) { LOG_ERROR("REPO", "Failed to add kara %ld to playlist %s", uri->uri.id, uri->fav); return; @@ -608,6 +609,8 @@ __handle_fav_list(struct module_repo_internal *repo, char *fav, size_t fav_size) }, }; + size_t len = json_parse_get_count(json, 2); + lkt_queue_send(repo->queue, lkt_event_db_update_total, (void *) (size_t) len); json_parse(json, 2, __handle_fav_list_internal, (void *) &uri); LOG_INFO("REPO", "Finished importing fav list '%s' as '%s'", fav_origin, fav); free(json); -- GitLab