| 2325 | } |
| 2326 | |
| 2327 | static bool application_index_args_add_policy(cbm_daemon_application_t *application, |
| 2328 | yyjson_mut_doc *document, yyjson_mut_val *root) { |
| 2329 | cbm_config_t *owned_config = NULL; |
| 2330 | cbm_config_t *config = application ? application->config : NULL; |
| 2331 | if (!config) { |
| 2332 | owned_config = cbm_config_open(cbm_resolve_cache_dir()); |
| 2333 | config = owned_config; |
| 2334 | } |
| 2335 | cbm_index_resource_policy_t policy; |
| 2336 | char error[CBM_SZ_256] = {0}; |
| 2337 | bool loaded = cbm_config_load_index_policy(config, &policy, error, sizeof(error)); |
| 2338 | /* The worker reads no config: a doc_candidates setting the user set |
| 2339 | * travels with the request; unset, the worker's index mode decides. */ |
| 2340 | bool doc_candidates_encoded = |
| 2341 | !loaded || cbm_mcp_index_doc_candidates_add_to_args(document, root, config); |
| 2342 | cbm_config_close(owned_config); |
| 2343 | if (!loaded) { |
| 2344 | cbm_log_error("daemon.index.policy", "error", error); |
| 2345 | return false; |
| 2346 | } |
| 2347 | return doc_candidates_encoded && cbm_mcp_index_policy_add_to_args(document, root, &policy); |
| 2348 | } |
| 2349 | |
| 2350 | static char *application_auto_index_args(cbm_daemon_application_t *application, |
| 2351 | const char *root_path) { |
no test coverage detected