Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 98e5f316 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

REPO: Prepare to dl favorites from kurisu

parent 623fec06
Branches
Étiquettes
1 requête de fusion!122Resolve "Import the "Favoris" from kurisu"
...@@ -98,7 +98,7 @@ makepkg -si ...@@ -98,7 +98,7 @@ makepkg -si
launch, because `XDG_RUNTIME_DIR` is not defined here. This folder is 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 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 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... 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 > Currently, supported compilers are: `icc` 19.1.2.254 and above, `gcc` 8.3.0 and
......
...@@ -24,8 +24,8 @@ value("url", "https://kurisu.iiens.net") ...@@ -24,8 +24,8 @@ value("url", "https://kurisu.iiens.net")
value("json", "https://kurisu.iiens.net/api") value("json", "https://kurisu.iiens.net/api")
value("id_json", "https://kurisu.iiens.net/api/%ld") value("id_json", "https://kurisu.iiens.net/api/%ld")
value("id_kara", "https://kurisu.iiens.net/api/download/%ld") value("id_kara", "https://kurisu.iiens.net/api/download/%ld")
value("fav_json", "https://kurisu.iiens.net/api/fav/%s") value("fav_json", "https://kurisu.iiens.net/api/fav/")
value("plt_json", "https://kurisu.iiens.net/api/plt/%s") value("plt_json", "https://kurisu.iiens.net/api/plt/")
/* The player module, so that people can 'sing' when using lektor. By /* 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 * default it's sdl, but one can create any module, for audio support
......
...@@ -43,6 +43,7 @@ struct module_repo_internal { ...@@ -43,6 +43,7 @@ struct module_repo_internal {
char *get_all_json; char *get_all_json;
char *get_id_json; char *get_id_json;
char *get_id_file; char *get_id_file;
char *get_fav_json;
const uint64_t version; const uint64_t version;
/* Worker threads */ /* Worker threads */
...@@ -489,27 +490,27 @@ __worker_import_favorites(void *__repo) ...@@ -489,27 +490,27 @@ __worker_import_favorites(void *__repo)
{ {
struct module_repo_internal *repo = __repo; struct module_repo_internal *repo = __repo;
// GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock); GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock);
// repo->updating &= REPO_UPDATE_FAV; repo->updating &= REPO_UPDATE_FAV;
// GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock); GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock);
// // struct json_object *json; // struct json_object *json;
// LOG_INFO("REPO", "Download favorite lists from %s (%s), directory is %s", LOG_INFO("REPO", "Download favorite lists from %s (%s), directory is %s",
// repo->name, repo->get_all_json, repo->kara_dir); repo->name, repo->get_all_json, repo->kara_dir);
// // if (__json_sync(repo, &json)) { // if (__json_sync(repo, &json)) {
// // LOG_ERROR("REPO", "Failed to get json, possibly no internet connexion or repo is down"); // LOG_ERROR("REPO", "Failed to get json, possibly no internet connexion or repo is down");
// // pthread_exit(NULL); // pthread_exit(NULL);
// // } // }
// // __handle_got_json(repo->db, repo, json); // __handle_got_json(repo->db, repo, json);
// // LOG_INFO("REPO", "Finished to download and insert kara list"); // LOG_INFO("REPO", "Finished to download and insert kara list");
// // json_object_put(json); // json_object_put(json);
// // __handle_deleted_kara(repo->db); // __handle_deleted_kara(repo->db);
// // LOG_INFO("REPO", "Finished to deal with deleted kara"); // LOG_INFO("REPO", "Finished to deal with deleted kara");
// // database_updated(repo->db); // database_updated(repo->db);
// GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock); GOTO_IF(pthread_mutex_lock(&(repo->mtx)), "Failed to lock", end_no_lock);
// repo->updating &= (~ REPO_UPDATE_FAV); repo->updating &= (~ REPO_UPDATE_FAV);
// GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock); GOTO_IF(pthread_mutex_unlock(&(repo->mtx)), "Failed to unlock", end_no_lock);
end_no_lock: end_no_lock:
pthread_exit(NULL); pthread_exit(NULL);
...@@ -559,6 +560,7 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil ...@@ -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)), .kara_dir = safe_zero_malloc(PATH_MAX * sizeof(char)),
.get_id_json = safe_zero_malloc(LKT_LINE_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_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)), .get_all_json = safe_zero_malloc(LKT_LINE_MAX * sizeof(char)),
.base_url = 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, .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 ...@@ -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", "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_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", "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) ) { !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"); LOG_ERROR("REPO", "Configuration invalid, but it should not be at this point");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -652,6 +655,7 @@ mod_free(va_list *va) ...@@ -652,6 +655,7 @@ mod_free(va_list *va)
free((*repo)->get_id_file); free((*repo)->get_id_file);
free((*repo)->base_url); free((*repo)->base_url);
free((*repo)->get_all_json); free((*repo)->get_all_json);
free((*repo)->get_fav_json);
LOG_INFO("REPO", "Repo module terminated"); LOG_INFO("REPO", "Repo module terminated");
va_end(copy); va_end(copy);
...@@ -740,6 +744,7 @@ mod_import(va_list *va) ...@@ -740,6 +744,7 @@ mod_import(va_list *va)
struct module_repo_internal **repo; struct module_repo_internal **repo;
va_copy(copy, *va); 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); GOTO_IF(pthread_mutex_lock(&(*repo)->mtx), "Failed to lock", end_no_lock);
if ((*repo)->updating & REPO_UPDATE_FAV) { if ((*repo)->updating & REPO_UPDATE_FAV) {
...@@ -748,11 +753,17 @@ mod_import(va_list *va) ...@@ -748,11 +753,17 @@ mod_import(va_list *va)
} }
(*repo)->updating &= REPO_UPDATE_FAV; (*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: end:
GOTO_IF(pthread_mutex_unlock(&(*repo)->mtx), "Failed to unlock", end_no_lock); GOTO_IF(pthread_mutex_unlock(&(*repo)->mtx), "Failed to unlock", end_no_lock);
end_no_lock: end_no_lock:
va_end(copy); va_end(copy);
return 0; return ret;
} }
REG_BEGIN(repo_reg) REG_BEGIN(repo_reg)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter