From 5034cd8af8b5f994e074aa76610a28a07c9862ad Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Sun, 8 May 2022 11:45:39 +0200 Subject: [PATCH] REPO: Update the unix ts to set it to the repo's one even if the kara is ignored in the update process --- src/module/module_repo.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/module/module_repo.c b/src/module/module_repo.c index 821e950f..91bc22b2 100644 --- a/src/module/module_repo.c +++ b/src/module/module_repo.c @@ -396,6 +396,20 @@ ___handle_got_json_dl(struct kara *kara) kara->filename); } +PRIVATE_FUNCTION void +___update_repo_timestamp_if_needed_on_ignore_kara(struct kara *kara, uint64_t repo_ts) +{ + uint64_t stored_ts = 0; + const bool found_ts = database_get_kara_repo_timestamp_id(kara->db, (int)kara->id, &stored_ts); + if ((!found_ts) || (stored_ts <= 0)) { + LOG_INFO("REPO", + "Update repo unix timestamp of kara %ld because it was " + "not present in the DB (update of the DB scheme)", + kara->id); + database_set_kara_repo_timestamp_id(kara->db, (int)kara->id, repo_ts); + } +} + PRIVATE_FUNCTION int ___handle_got_json_internal_callback(const char *key, const char *val, int comp, void *user) { @@ -514,10 +528,8 @@ ___handle_got_json_internal_callback(const char *key, const char *val, int comp, /* Ignore kara */ else { ++(kara->ignored_count); - - /* Don't burn the disk */ - ___sleep(); - + ___update_repo_timestamp_if_needed_on_ignore_kara(kara, (uint64_t)kara->unix_timestamp); + ___sleep(); /* Don't burn the disk */ lkt_queue_send(kara->repo->queue, LKT_EVENT_TOUCH_KARA, (void *)(size_t)kara->id); lkt_queue_send(kara->repo->queue, LKT_EVENT_DB_UPDATE_TICK, NULL); LOG_DEBUG("REPO", "Ignore kara %ld", kara->id); @@ -527,6 +539,7 @@ ___handle_got_json_internal_callback(const char *key, const char *val, int comp, do_it: /* Even if we must download the kara, the user could have filtered it out! */ if (lkt_uri_match_kara_metadata(filter, &kara->mdt, kara->db, (int)kara->id)) { + ___update_repo_timestamp_if_needed_on_ignore_kara(kara, (uint64_t)kara->unix_timestamp); LOG_DEBUG("REPO", "The kara %ld is ignored because it was filtered out", kara->id); ++(kara->ignored_count); return 0; -- GitLab