mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
history_add() now creates an etag.
This commit is contained in:
parent
5c7b26bcdc
commit
dae2e406d6
8
data.c
8
data.c
@ -1677,7 +1677,8 @@ double history_mtime(snac *snac, const char *id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void history_add(snac *snac, const char *id, const char *content, int size)
|
void history_add(snac *snac, const char *id, const char *content, int size,
|
||||||
|
xs_str **etag)
|
||||||
/* adds something to the history */
|
/* adds something to the history */
|
||||||
{
|
{
|
||||||
xs *fn = _history_fn(snac, id);
|
xs *fn = _history_fn(snac, id);
|
||||||
@ -1686,6 +1687,11 @@ void history_add(snac *snac, const char *id, const char *content, int size)
|
|||||||
if (fn && (f = fopen(fn, "w")) != NULL) {
|
if (fn && (f = fopen(fn, "w")) != NULL) {
|
||||||
fwrite(content, size, 1, f);
|
fwrite(content, size, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
if (etag) {
|
||||||
|
double tm = mtime(fn);
|
||||||
|
*etag = xs_fmt("W/\"snac-%.0lf\"", tm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
html.c
4
html.c
@ -1891,7 +1891,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
status = 200;
|
status = 200;
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
history_add(&snac, h, *body, *b_size);
|
history_add(&snac, h, *body, *b_size, etag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1922,7 +1922,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
status = 200;
|
status = 200;
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
history_add(&snac, "timeline.html_", *body, *b_size);
|
history_add(&snac, "timeline.html_", *body, *b_size, etag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
snac.h
3
snac.h
@ -149,7 +149,8 @@ void static_put_meta(snac *snac, const char *id, const char *str);
|
|||||||
xs_str *static_get_meta(snac *snac, const char *id);
|
xs_str *static_get_meta(snac *snac, const char *id);
|
||||||
|
|
||||||
double history_mtime(snac *snac, const char *id);
|
double history_mtime(snac *snac, const char *id);
|
||||||
void history_add(snac *snac, const char *id, const char *content, int size);
|
void history_add(snac *snac, const char *id, const char *content, int size,
|
||||||
|
xs_str **etag);
|
||||||
int history_get(snac *snac, const char *id, xs_str **content, int *size,
|
int history_get(snac *snac, const char *id, xs_str **content, int *size,
|
||||||
const char *inm, xs_str **etag);
|
const char *inm, xs_str **etag);
|
||||||
int history_del(snac *snac, const char *id);
|
int history_del(snac *snac, const char *id);
|
||||||
|
Loading…
Reference in New Issue
Block a user