mirror of
https://github.com/owntracks/recorder.git
synced 2026-04-09 00:36:50 +00:00
9
ghash.c
9
ghash.c
@@ -105,7 +105,7 @@ int ghash_readcache(struct udata *ud, char *ghash, UT_string *addr, UT_string *c
|
||||
|
||||
if (ud->usefiles) {
|
||||
/* if ghash file is available, read cc:addr into that */
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/%s.json", JSONDIR, ghash);
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s/%s.json", JSONDIR, ghash, ghash);
|
||||
|
||||
fprintf(stderr, "Reading GhashCache from %s\n", gfile);
|
||||
if ((fp = fopen(gfile, "r")) != NULL) {
|
||||
@@ -168,7 +168,12 @@ void ghash_storecache(struct udata *ud, JsonNode *geo, char *ghash, char *addr,
|
||||
json_append_member(geo, "cc", json_mkstring(ghash));
|
||||
|
||||
if ((js = json_stringify(geo, NULL)) != NULL) {
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/%s.json", JSONDIR, ghash);
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s", JSONDIR, ghash);
|
||||
if (mkpath(gfile) != 0) {
|
||||
perror(gfile);
|
||||
return;
|
||||
}
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s/%s.json", JSONDIR, ghash, ghash);
|
||||
|
||||
if ((fp = fopen(gfile, "w")) != NULL) {
|
||||
fprintf(fp, "%s\n", js);
|
||||
|
||||
Reference in New Issue
Block a user