diff options
author | default <nobody@localhost> | 2022-11-26 05:18:48 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2022-11-26 05:18:48 +0100 |
commit | 1243e26a0d883b0aa3f368e11b37591fe0fef1bf (patch) | |
tree | 54797da191c9ad8ad955ba3e53bf2066592c5c71 /data.c | |
parent | 17d4e4f5dda370f96d28362edb2f6213a702500e (diff) |
New function object_add_ow().
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -428,14 +428,14 @@ int object_get(const char *id, d_char **obj, const char *type) } -int object_add(const char *id, d_char *obj) +int _object_add(const char *id, d_char *obj, int ow) /* stores an object */ { int status = 201; /* Created */ xs *fn = _object_fn(id); FILE *f; - if (mtime(fn) > 0.0) { + if (!ow && mtime(fn) > 0.0) { /* object already here */ srv_debug(0, xs_fmt("object_add object already here %s", id)); return 204; /* No content */ @@ -471,6 +471,20 @@ int object_add(const char *id, d_char *obj) } +int object_add(const char *id, d_char *obj) +/* stores an object */ +{ + return _object_add(id, obj, 0); +} + + +int object_add_ow(const char *id, d_char *obj) +/* stores an object (overwriting allowed) */ +{ + return _object_add(id, obj, 1); +} + + int object_del_by_md5(const char *md5) /* deletes an object by its md5 */ { @@ -1231,7 +1245,7 @@ int is_hidden(snac *snac, const char *id) int actor_add(snac *snac, const char *actor, d_char *msg) /* adds an actor */ { - return object_add(actor, msg); + return object_add_ow(actor, msg); } @@ -1381,6 +1395,8 @@ d_char *history_list(snac *snac) } +/** the queue **/ + static int _enqueue_put(char *fn, char *msg) /* writes safely to the queue */ { @@ -1527,6 +1543,8 @@ d_char *dequeue(snac *snac, char *fn) } +/** the purge **/ + static void _purge_file(const char *fn, time_t mt) /* purge fn if it's older than days */ { |