]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Reduce severity of metadata.json not found
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 3 Oct 2023 20:07:26 +0000 (14:07 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 3 Oct 2023 20:13:42 +0000 (14:13 -0600)
Also improve the error messages by including the actual name of the
file.

src/cache/local_cache.c

index 41099cfa1ef6bec4b1a4c3f6293c633792d7473c..e8c162964e2dcc58a174c9de5e9fd3bf1a6dd6ae 100644 (file)
@@ -302,15 +302,17 @@ load_metadata_json(void)
 
        root = json_load_file(filename, 0, &jerror);
 
-       free(filename);
-
        if (root == NULL) {
-               pr_op_err("Json parsing failure at metadata.json (%d:%d): %s",
-                   jerror.line, jerror.column, jerror.text);
+               if (json_error_code(&jerror) == json_error_cannot_open_file) {
+                       pr_op_debug("%s does not exist.", filename);
+               } else {
+                       pr_op_err("Json parsing failure at %s (%d:%d): %s",
+                           filename, jerror.line, jerror.column, jerror.text);
+               }
                goto end;
        }
        if (json_typeof(root) != JSON_ARRAY) {
-               pr_op_err("The root tag of metadata.json is not an array.");
+               pr_op_err("The root tag of %s is not an array.", filename);
                goto end;
        }
 
@@ -323,13 +325,14 @@ load_metadata_json(void)
                else if (strcasecmp(node->basename, "https") == 0)
                        https = node;
                else {
-                       pr_op_warn("Ignoring unrecognized json node '%s'.",
-                           node->basename);
+                       pr_op_warn("%s: Ignoring unrecognized json node '%s'.",
+                           filename, node->basename);
                        delete_node(node);
                }
        }
 
 end:
+       free(filename);
        json_decref(root);
 }