diff options
| author | 2022-11-24 08:36:01 +0100 | |
|---|---|---|
| committer | 2022-11-24 08:36:01 +0100 | |
| commit | b0b052ab3b724ded9b13e2703dc7f0138a0b9a4f (patch) | |
| tree | 7489c5cfa1a8718ef925b142d612718e70bb66be | |
| parent | Don't create an actors/ subdirectory in add user. (diff) | |
| download | snac2-b0b052ab3b724ded9b13e2703dc7f0138a0b9a4f.tar.gz snac2-b0b052ab3b724ded9b13e2703dc7f0138a0b9a4f.tar.xz snac2-b0b052ab3b724ded9b13e2703dc7f0138a0b9a4f.zip | |
Function object_del() also deletes the indexes.
| -rw-r--r-- | data.c | 19 |
1 files changed, 17 insertions, 2 deletions
| @@ -424,10 +424,23 @@ int object_del(const char *id) | |||
| 424 | int status = 404; | 424 | int status = 404; |
| 425 | xs *fn = _object_fn(id); | 425 | xs *fn = _object_fn(id); |
| 426 | 426 | ||
| 427 | if (fn != NULL && unlink(fn) != -1) | 427 | if (fn != NULL && unlink(fn) != -1) { |
| 428 | status = 200; | 428 | status = 200; |
| 429 | 429 | ||
| 430 | srv_debug(2, xs_fmt("object_del %s %d", id, status)); | 430 | /* also delete associated indexes */ |
| 431 | xs *spec = _object_fn(id); | ||
| 432 | spec = xs_replace_i(spec, ".json", "*.idx"); | ||
| 433 | xs *files = xs_glob(spec, 0, 0); | ||
| 434 | char *p, *v; | ||
| 435 | |||
| 436 | p = files; | ||
| 437 | while (xs_list_iter(&p, &v)) { | ||
| 438 | srv_debug(0, xs_fmt("object_del index %s", v)); | ||
| 439 | unlink(v); | ||
| 440 | } | ||
| 441 | } | ||
| 442 | |||
| 443 | srv_debug(0, xs_fmt("object_del %s %d", id, status)); | ||
| 431 | 444 | ||
| 432 | return status; | 445 | return status; |
| 433 | } | 446 | } |
| @@ -601,6 +614,8 @@ int timeline_del(snac *snac, char *id) | |||
| 601 | ret = 200; | 614 | ret = 200; |
| 602 | } | 615 | } |
| 603 | 616 | ||
| 617 | object_del(id); | ||
| 618 | |||
| 604 | return ret; | 619 | return ret; |
| 605 | } | 620 | } |
| 606 | 621 | ||