diff options
| author | 2023-08-19 09:59:58 +0200 | |
|---|---|---|
| committer | 2023-08-19 09:59:58 +0200 | |
| commit | dae2e406d633ba32f2660100ef417ec13726765c (patch) | |
| tree | f0fc2ee7f826907665ff883cd205d1f355030a2c /data.c | |
| parent | static_get() and history_get() both share the same code. (diff) | |
| download | snac2-dae2e406d633ba32f2660100ef417ec13726765c.tar.gz snac2-dae2e406d633ba32f2660100ef417ec13726765c.tar.xz snac2-dae2e406d633ba32f2660100ef417ec13726765c.zip | |
history_add() now creates an etag.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 8 |
1 files changed, 7 insertions, 1 deletions
| @@ -1677,7 +1677,8 @@ double history_mtime(snac *snac, const char *id) | |||
| 1677 | } | 1677 | } |
| 1678 | 1678 | ||
| 1679 | 1679 | ||
| 1680 | void history_add(snac *snac, const char *id, const char *content, int size) | 1680 | void history_add(snac *snac, const char *id, const char *content, int size, |
| 1681 | xs_str **etag) | ||
| 1681 | /* adds something to the history */ | 1682 | /* adds something to the history */ |
| 1682 | { | 1683 | { |
| 1683 | xs *fn = _history_fn(snac, id); | 1684 | xs *fn = _history_fn(snac, id); |
| @@ -1686,6 +1687,11 @@ void history_add(snac *snac, const char *id, const char *content, int size) | |||
| 1686 | if (fn && (f = fopen(fn, "w")) != NULL) { | 1687 | if (fn && (f = fopen(fn, "w")) != NULL) { |
| 1687 | fwrite(content, size, 1, f); | 1688 | fwrite(content, size, 1, f); |
| 1688 | fclose(f); | 1689 | fclose(f); |
| 1690 | |||
| 1691 | if (etag) { | ||
| 1692 | double tm = mtime(fn); | ||
| 1693 | *etag = xs_fmt("W/\"snac-%.0lf\"", tm); | ||
| 1694 | } | ||
| 1689 | } | 1695 | } |
| 1690 | } | 1696 | } |
| 1691 | 1697 | ||