Merge branch 'unstable' into redis_6_merge

Former-commit-id: 4671cd6002c50dd8484e59fd7434878053340702
This commit is contained in:
John Sully 2020-03-15 18:47:27 -04:00
commit c7f1eab8a4
4 changed files with 15 additions and 1 deletions

View File

@ -23,7 +23,7 @@ static const char *szMotdCachePath()
return ""; return "";
const char *homedir = pw->pw_dir; const char *homedir = pw->pw_dir;
sdsMotdCachePath = sdsnew(homedir); sdsMotdCachePath = sdsnew(homedir);
sdsMotdCachePath = sdscat(sdsMotdCachePath, "/.keydb-cli-motd"); sdsMotdCachePath = sdscat(sdsMotdCachePath, motd_cache_file);
return sdsMotdCachePath; return sdsMotdCachePath;
} }
static size_t motd_write_callback(void *ptr, size_t size, size_t nmemb, sds *str) static size_t motd_write_callback(void *ptr, size_t size, size_t nmemb, sds *str)
@ -101,6 +101,17 @@ extern "C" char *fetchMOTD(int cache)
sdsfree(str); sdsfree(str);
str = NULL; str = NULL;
} }
else
{
long response_code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
if ((response_code / 100) != 2)
{
// An error code not in the 200s implies an error
sdsfree(str);
str = NULL;
}
}
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
extern const char *motd_url; extern const char *motd_url;
extern const char *motd_cache_file;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -97,6 +97,7 @@ int spectrum_palette_size;
int g_fInCrash = 0; int g_fInCrash = 0;
const char *motd_url = "http://api.keydb.dev/motd/motd_cli.txt"; const char *motd_url = "http://api.keydb.dev/motd/motd_cli.txt";
const char *motd_cache_file = "/.keydb-cli-motd";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Utility functions * Utility functions

View File

@ -66,6 +66,7 @@
int g_fTestMode = false; int g_fTestMode = false;
const char *motd_url = "http://api.keydb.dev/motd/motd_server.txt"; const char *motd_url = "http://api.keydb.dev/motd/motd_server.txt";
const char *motd_cache_file = "/.keydb-server-motd";
/* Our shared "common" objects */ /* Our shared "common" objects */