diff --git a/README.md b/README.md index 157a5339ac66a01ec72dc37d0f329429a606f0df..37e3e1ae3dfaf83ef9a3c61a9500f51a337c50d2 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ makepkg -si launch, because `XDG_RUNTIME_DIR` is not defined here. This folder is important, this is where most of your deamons are puttings theirs sockets and so. Blame Microsoft for that. A workaround is to export one: `export -WDG_RUNTIME_DIR=$(mktemp -d)` before launching lektord. Be aware that you will +XDG_RUNTIME_DIR=$(mktemp -d)` before launching lektord. Be aware that you will have issues with sound and videos becouse you will need to set up a X server... > Currently, supported compilers are: `icc` 19.1.2.254 and above, `gcc` 8.3.0 and diff --git a/inc/lektor/config.def b/inc/lektor/config.def index a510c7bc975f5123ec4531be2a3cccd2050e1d84..5756920f47c46a4bd5a2e695a6230a465cec15cd 100644 --- a/inc/lektor/config.def +++ b/inc/lektor/config.def @@ -24,8 +24,8 @@ value("url", "https://kurisu.iiens.net") value("json", "https://kurisu.iiens.net/api") value("id_json", "https://kurisu.iiens.net/api/%ld") value("id_kara", "https://kurisu.iiens.net/api/download/%ld") -value("fav_json", "https://kurisu.iiens.net/api/fav/%s") -value("plt_json", "https://kurisu.iiens.net/api/plt/%s") +value("fav_json", "https://kurisu.iiens.net/api/fav/") +value("plt_json", "https://kurisu.iiens.net/api/plt/") /* The player module, so that people can 'sing' when using lektor. By * default it's sdl, but one can create any module, for audio support diff --git a/src/module/module_repo.c b/src/module/module_repo.c index d129c07724476cbf8ad775ff5e850c534e2a7773..63ab1adfcb1a8d49816e9b56fddb7b2138a8bd02 100644 --- a/src/module/module_repo.c +++ b/src/module/module_repo.c @@ -43,6 +43,7 @@ struct module_repo_internal { char *get_all_json; char *get_id_json; char *get_id_file; + char *get_fav_json; const uint64_t version; /* Worker threads */ @@ -489,27 +490,27 @@ __worker_import_favorites(void *__repo) { struct module_repo_internal *repo = __repo; - // GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock); - // repo->updating &= REPO_UPDATE_FAV; - // GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock); - - // // struct json_object *json; - // LOG_INFO("REPO", "Download favorite lists from %s (%s), directory is %s", - // repo->name, repo->get_all_json, repo->kara_dir); - // // if (__json_sync(repo, &json)) { - // // LOG_ERROR("REPO", "Failed to get json, possibly no internet connexion or repo is down"); - // // pthread_exit(NULL); - // // } - // // __handle_got_json(repo->db, repo, json); - // // LOG_INFO("REPO", "Finished to download and insert kara list"); - // // json_object_put(json); - // // __handle_deleted_kara(repo->db); - // // LOG_INFO("REPO", "Finished to deal with deleted kara"); - // // database_updated(repo->db); - - // GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock); - // repo->updating &= (~ REPO_UPDATE_FAV); - // GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock); + GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock); + repo->updating &= REPO_UPDATE_FAV; + GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock); + + // struct json_object *json; + LOG_INFO("REPO", "Download favorite lists from %s (%s), directory is %s", + repo->name, repo->get_all_json, repo->kara_dir); + // if (__json_sync(repo, &json)) { + // LOG_ERROR("REPO", "Failed to get json, possibly no internet connexion or repo is down"); + // pthread_exit(NULL); + // } + // __handle_got_json(repo->db, repo, json); + // LOG_INFO("REPO", "Finished to download and insert kara list"); + // json_object_put(json); + // __handle_deleted_kara(repo->db); + // LOG_INFO("REPO", "Finished to deal with deleted kara"); + // database_updated(repo->db); + + GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock); + repo->updating &= (~ REPO_UPDATE_FAV); + GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock); end_no_lock: pthread_exit(NULL); @@ -559,6 +560,7 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil .kara_dir = safe_zero_malloc(PATH_MAX * sizeof(char)), .get_id_json = safe_zero_malloc(LKT_LINE_MAX * sizeof(char)), .get_id_file = safe_zero_malloc(LKT_LINE_MAX * sizeof(char)), + .get_fav_json = safe_zero_malloc(LKT_LINE_MAX * sizeof(char)), .get_all_json = safe_zero_malloc(LKT_LINE_MAX * sizeof(char)), .base_url = safe_zero_malloc(LKT_LINE_MAX * sizeof(char)), .craft_filename = obfuscate ? __craft_filename_obfuscate : __craft_filename_non_obfuscate, @@ -570,6 +572,7 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil !database_config_get_text(db, "repo", "url", repo.base_url, LKT_LINE_MAX) || !database_config_get_text(db, "repo", "id_json", repo.get_id_json, LKT_LINE_MAX) || !database_config_get_text(db, "repo", "id_kara", repo.get_id_file, LKT_LINE_MAX) || + !database_config_get_text(db, "repo", "fav_json", repo.get_fav_json, LKT_LINE_MAX) || !database_config_get_text(db, "repo", "json", repo.get_all_json, LKT_LINE_MAX) ) { LOG_ERROR("REPO", "Configuration invalid, but it should not be at this point"); exit(EXIT_FAILURE); @@ -652,6 +655,7 @@ mod_free(va_list *va) free((*repo)->get_id_file); free((*repo)->base_url); free((*repo)->get_all_json); + free((*repo)->get_fav_json); LOG_INFO("REPO", "Repo module terminated"); va_end(copy); @@ -739,7 +743,8 @@ mod_import(va_list *va) va_list copy; struct module_repo_internal **repo; va_copy(copy, *va); - repo = (struct module_repo_internal **) va_arg(copy, void **); + repo = (struct module_repo_internal **) va_arg(copy, void **); + int ret = 0; GOTO_IF(pthread_mutex_lock(&(*repo)->mtx), "Failed to lock", end_no_lock); if ((*repo)->updating & REPO_UPDATE_FAV) { @@ -748,11 +753,17 @@ mod_import(va_list *va) } (*repo)->updating &= REPO_UPDATE_FAV; + if (worker_pool_push(&(*repo)->workers, __worker_import_favorites, (void *) *repo)) { + LOG_ERROR("REPO", "Out of memory"); + ret = 1; + goto end; + } + end: GOTO_IF(pthread_mutex_unlock(&(*repo)->mtx), "Failed to unlock", end_no_lock); end_no_lock: va_end(copy); - return 0; + return ret; } REG_BEGIN(repo_reg)