app: make update detection more robust to string revision field.

The "revision" field in the json file is supposed to be int. But I just
realized that it was set as string a few times, e.g. in Windows
installer revision 1 of GIMP 2.10.32. As a consequence, the revision 0
build was not able to detect the new revision.

I have now fixed the data in gimp-web repo (commit e7690e36), yet just
in case this ever happens again, I make the parsing code more robust by
accepting string revision, then properly converted to int.
This commit is contained in:
Jehan 2022-06-21 22:31:36 +02:00
parent e3c7791acc
commit b79d26f097
1 changed files with 8 additions and 1 deletions

View File

@ -268,7 +268,14 @@ gimp_update_get_highest (JsonParser *parser,
/* These are optional data. */
if (json_object_has_member (build, "revision"))
*build_revision = json_object_get_int_member (build, "revision");
{
if (g_strcmp0 (json_node_type_name (json_object_get_member (build, "revision")),
"String") == 0)
*build_revision = g_ascii_strtoull (json_object_get_string_member (build, "revision"),
NULL, 10);
else
*build_revision = json_object_get_int_member (build, "revision");
}
if (json_object_has_member (build, "comment"))
*build_comment = g_strdup (json_object_get_string_member (build, "comment"));
break;