diff options
| author | 2022-11-26 05:58:13 +0100 | |
|---|---|---|
| committer | 2022-11-26 05:58:13 +0100 | |
| commit | 8e83821eeec1fb967afb4b26896271c6106c25ef (patch) | |
| tree | 84951a78a1a5a615cb8a420c8e7fa3c022b25663 | |
| parent | New function object_user_cache_del(). (diff) | |
| download | snac2-8e83821eeec1fb967afb4b26896271c6106c25ef.tar.gz snac2-8e83821eeec1fb967afb4b26896271c6106c25ef.tar.xz snac2-8e83821eeec1fb967afb4b26896271c6106c25ef.zip | |
_object_user_cache() also update the indexes.
| -rw-r--r-- | data.c | 24 |
1 files changed, 13 insertions, 11 deletions
| @@ -562,8 +562,19 @@ int _object_user_cache(snac *snac, const char *id, const char *cachedir, int del | |||
| 562 | xs *ofn = _object_fn(id); | 562 | xs *ofn = _object_fn(id); |
| 563 | xs *l = xs_split(ofn, "/"); | 563 | xs *l = xs_split(ofn, "/"); |
| 564 | xs *cfn = xs_fmt("%s/%s/%s", snac->basedir, cachedir, xs_list_get(l, -1)); | 564 | xs *cfn = xs_fmt("%s/%s/%s", snac->basedir, cachedir, xs_list_get(l, -1)); |
| 565 | xs *idx = xs_fmt("%s/%s.idx", snac->basedir, cachedir); | ||
| 566 | int ret; | ||
| 565 | 567 | ||
| 566 | return del ? unlink(cfn) : link(ofn, cfn); | 568 | if (del) { |
| 569 | index_del(idx, id); | ||
| 570 | ret = unlink(cfn); | ||
| 571 | } | ||
| 572 | else { | ||
| 573 | index_add(idx, id); | ||
| 574 | ret = link(ofn, cfn); | ||
| 575 | } | ||
| 576 | |||
| 577 | return ret; | ||
| 567 | } | 578 | } |
| 568 | 579 | ||
| 569 | 580 | ||
| @@ -959,19 +970,10 @@ int _timeline_write(snac *snac, char *id, char *msg, char *parent, char *referre | |||
| 959 | void timeline_update_indexes(snac *snac, const char *id) | 970 | void timeline_update_indexes(snac *snac, const char *id) |
| 960 | /* updates the indexes */ | 971 | /* updates the indexes */ |
| 961 | { | 972 | { |
| 962 | /* add to the private index */ | ||
| 963 | xs *idx = xs_fmt("%s/private.idx", snac->basedir); | ||
| 964 | index_add(idx, id); | ||
| 965 | |||
| 966 | object_user_cache_add(snac, id, "private"); | 973 | object_user_cache_add(snac, id, "private"); |
| 967 | 974 | ||
| 968 | if (xs_startswith(id, snac->actor)) { | 975 | if (xs_startswith(id, snac->actor)) |
| 969 | /* add to the public index */ | ||
| 970 | idx = xs_replace_i(idx, "private", "public"); | ||
| 971 | index_add(idx, id); | ||
| 972 | |||
| 973 | object_user_cache_add(snac, id, "public"); | 976 | object_user_cache_add(snac, id, "public"); |
| 974 | } | ||
| 975 | } | 977 | } |
| 976 | 978 | ||
| 977 | 979 | ||