@cryptotaxi247 / netdata-1 / commits / 92d48b177

Return stable or nightly based on version if the file check fails (#12894)

Stelios Fragkakis committed May 13, 2022 at 12:48 UTC 92d48b177862e0b0d1957a0c97db80d4294e7884
1 file changed +13 -13
web/api/formatters/charts2json.c
+13 -13
@@ -8,30 +8,30 @@ const char* get_release_channel() {
8 static int use_stable = -1;
9
10 if (use_stable == -1) {
11 - char filename[FILENAME_MAX + 1];
11 + char filename[FILENAME_MAX + 1];
12 snprintfz(filename, FILENAME_MAX, "%s/.environment", netdata_configured_user_config_dir);
13 procfile *ff = procfile_open(filename, "=", PROCFILE_FLAG_DEFAULT);
14 - if(!ff) {
15 - use_stable=1;
16 - } else {
14 + if (ff) {
15 procfile_set_quotes(ff, "'\"");
16 ff = procfile_readall(ff);
19 - if(!ff) {
20 - use_stable=1;
21 - } else {
17 + if (ff) {
18 unsigned int i;
23 - for(i = 0; i < procfile_lines(ff); i++) {
24 - if (!procfile_linewords(ff, i)) continue;
25 -
26 - if (!strcmp(procfile_lineword(ff, i, 0), "RELEASE_CHANNEL") && !strcmp(procfile_lineword(ff, i, 1), "stable")) {
27 - use_stable = 1;
19 + for (i = 0; i < procfile_lines(ff); i++) {
20 + if (!procfile_linewords(ff, i))
21 + continue;
22 + if (!strcmp(procfile_lineword(ff, i, 0), "RELEASE_CHANNEL")) {
23 + if (!strcmp(procfile_lineword(ff, i, 1), "stable"))
24 + use_stable = 1;
25 + else if (!strcmp(procfile_lineword(ff, i, 1), "nightly"))
26 + use_stable = 0;
27 break;
28 }
29 }
30 procfile_close(ff);
32 - if (use_stable == -1) use_stable = 0;
31 }
32 }
33 + if (use_stable == -1)
34 + use_stable = strchr(program_version, '-') ? 0 : 1;
35 }
36 return (use_stable)?"stable":"nightly";
37 }