summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/data.c b/data.c
index bc80b1b..f5bd131 100644
--- a/data.c
+++ b/data.c
@@ -193,7 +193,7 @@ double mtime(char *fn)
193 193
194/** database 2.1+ **/ 194/** database 2.1+ **/
195 195
196int index_add(const char *fn, const char *md5) 196int index_add_md5(const char *fn, const char *md5)
197/* adds an md5 to an index */ 197/* adds an md5 to an index */
198{ 198{
199 int status = 200; 199 int status = 200;
@@ -212,6 +212,15 @@ int index_add(const char *fn, const char *md5)
212} 212}
213 213
214 214
215int index_add(const char *fn, const char *id)
216/* adds an id to an index */
217{
218 xs *md5 = xs_md5_hex(id, strlen(id));
219
220 return index_add_md5(fn, md5);
221}
222
223
215int index_del(const char *fn, const char *md5) 224int index_del(const char *fn, const char *md5)
216/* deletes an md5 from an index */ 225/* deletes an md5 from an index */
217{ 226{
@@ -386,6 +395,19 @@ int object_add(const char *id, d_char *obj)
386 395
387 fwrite(j, strlen(j), 1, f); 396 fwrite(j, strlen(j), 1, f);
388 fclose(f); 397 fclose(f);
398
399 /* does this object has a parent? */
400 char *in_reply_to = xs_dict_get(obj, "inReplyTo");
401
402 if (!xs_is_null(in_reply_to)) {
403 /* update the children index of the parent */
404 xs *pfn = _object_fn(in_reply_to);
405
406 if (mtime(pfn) > 0.0) {
407 pfn = xs_replace_i(pfn, ".json", "_c.idx");
408 index_add(pfn, id);
409 }
410 }
389 } 411 }
390 else 412 else
391 status = 500; 413 status = 500;