summaryrefslogtreecommitdiff
path: root/src/portal
diff options
context:
space:
mode:
Diffstat (limited to 'src/portal')
-rw-r--r--src/portal/src/post.c3
-rw-r--r--src/portal/src/search.c20
2 files changed, 11 insertions, 12 deletions
diff --git a/src/portal/src/post.c b/src/portal/src/post.c
index 6ca8f23..1a8cb20 100644
--- a/src/portal/src/post.c
+++ b/src/portal/src/post.c
@@ -14,7 +14,8 @@ void camu_post_clone(struct camu_post *dest, struct camu_post *src)
dest->type = src->type;
al_str_clone(&dest->unique_id, &src->unique_id);
al_str_clone(&dest->url, &src->url);
- al_array_clone(dest->dates, src->dates);
+ al_array_init(dest->dates);
+ al_array_copy(dest->dates, src->dates);
al_str_clone(&dest->author.unique_id, &src->author.unique_id);
al_wstr_clone(&dest->author.username, &src->author.username);
al_wstr_clone(&dest->author.display_name, &src->author.display_name);
diff --git a/src/portal/src/search.c b/src/portal/src/search.c
index ab14d0e..c66e7a8 100644
--- a/src/portal/src/search.c
+++ b/src/portal/src/search.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "portal"
#include <al/log.h>
#include "../../server/common.h"
@@ -19,12 +20,12 @@ bool camu_python_init(void)
PyStatus status = Py_PreInitialize(&pre_config);
if (PyStatus_Exception(status)) {
- al_log_error("portal", "Preinitialization failed.");
+ error("Preinitialization failed.");
return false;
}
if (PyImport_AppendInittab("portal", PyInit_portal) == -1) {
- al_log_error("portal", "Could not extend in-built modules table.");
+ error("Could not extend in-built modules table.");
return false;
}
@@ -33,7 +34,7 @@ bool camu_python_init(void)
PyObject *module = PyImport_ImportModule("portal");
if (!module) {
PyErr_Print();
- al_log_error("portal", "Could not import module.");
+ error("Could not import module.");
goto err;
}
@@ -72,7 +73,7 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
if (!have_python) {
// Defer python init.
if (!(have_python = camu_python_init())) {
- al_log_error("portal", "Failed to initialize python.");
+ error("Failed to initialize python.");
break;
}
}
@@ -95,9 +96,9 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
al_array_init(search->pages);
search->bridge = bridge;
al_array_push(bridge->searches, search);
- al_log_info("portal", "New search %x (%.*s).", result.id, al_str_fmt(&cmd->query));
+ info("New search %x (%.*s).", result.id, al_str_x(&cmd->query));
} else {
- al_log_info("portal", "Failed to create search (%.*s).", al_str_fmt(&cmd->query));
+ info("Failed to create search (%.*s).", al_str_x(&cmd->query));
}
al_str_free(&cmd->module);
al_str_free(&cmd->query);
@@ -107,17 +108,14 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
struct camu_search *search = get_search_by_id(bridge, cmd->id);
if (search) {
result.id = search->id;
-
struct camu_result_page *page;
al_array_foreach_ptr(search->pages, j, page) {
if (page->num == cmd->num) break;
}
-
- al_log_info("portal", "Loading page %i (%.*s).", cmd->num, al_str_fmt(&search->query));
+ info("Loading page %i (%.*s).", cmd->num, al_str_x(&search->query));
if (portal_bridge_get_page(search, search->id, cmd->num) == -1) {
break;
}
-
result.page = &al_array_at(search->pages, cmd->num);
if (bridge->cache) {
struct camu_post *post;
@@ -126,7 +124,7 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
}
}
} else {
- al_log_info("portal", "Requested search doesn't exist (id: %d).", search->id);
+ info("Requested search doesn't exist (id: %d).", search->id);
result.id = -1;
}
break;