diff --git a/src/module/module_repo.c b/src/module/module_repo.c index 821e950f3dd01e0fac50a7075d5e5076358fb4f5..91bc22b285f75bd768ad3420025488ccf4fc8556 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;