summaryrefslogtreecommitdiff
path: root/internal/timeline/remove.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-11-22 19:38:10 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-22 18:38:10 +0000
commit50dc179d332af4a3dc0e69e2c4e39bbbccd3fec5 (patch)
treeb48421907353aa6530a76f8c345e3bc11aeab4c9 /internal/timeline/remove.go
parent[docs] Document http/s/socks5 proxy use (#1118) (diff)
downloadgotosocial-50dc179d332af4a3dc0e69e2c4e39bbbccd3fec5.tar.xz
[feature] Prune timelines once per hour to plug memory leak (#1117)
* export highest/lowest ULIDs as proper const * add stop + start to timeline manager, other small fixes * unexport unused interface funcs + tidy up * add LastGot func * add timeline Prune function * test prune * update lastGot
Diffstat (limited to 'internal/timeline/remove.go')
-rw-r--r--internal/timeline/remove.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/internal/timeline/remove.go b/internal/timeline/remove.go
index 1e70e28a7..4539a5232 100644
--- a/internal/timeline/remove.go
+++ b/internal/timeline/remove.go
@@ -29,7 +29,6 @@ import (
func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
l := log.WithFields(kv.Fields{
-
{"accountTimeline", t.accountID},
{"statusID", statusID},
}...)
@@ -40,9 +39,9 @@ func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
// remove entr(ies) from the post index
removeIndexes := []*list.Element{}
- if t.itemIndex != nil && t.itemIndex.data != nil {
- for e := t.itemIndex.data.Front(); e != nil; e = e.Next() {
- entry, ok := e.Value.(*itemIndexEntry)
+ if t.indexedItems != nil && t.indexedItems.data != nil {
+ for e := t.indexedItems.data.Front(); e != nil; e = e.Next() {
+ entry, ok := e.Value.(*indexedItemsEntry)
if !ok {
return removed, errors.New("Remove: could not parse e as a postIndexEntry")
}
@@ -53,7 +52,7 @@ func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
}
}
for _, e := range removeIndexes {
- t.itemIndex.data.Remove(e)
+ t.indexedItems.data.Remove(e)
removed++
}
@@ -82,19 +81,19 @@ func (t *timeline) Remove(ctx context.Context, statusID string) (int, error) {
func (t *timeline) RemoveAllBy(ctx context.Context, accountID string) (int, error) {
l := log.WithFields(kv.Fields{
-
{"accountTimeline", t.accountID},
{"accountID", accountID},
}...)
+
t.Lock()
defer t.Unlock()
var removed int
// remove entr(ies) from the post index
removeIndexes := []*list.Element{}
- if t.itemIndex != nil && t.itemIndex.data != nil {
- for e := t.itemIndex.data.Front(); e != nil; e = e.Next() {
- entry, ok := e.Value.(*itemIndexEntry)
+ if t.indexedItems != nil && t.indexedItems.data != nil {
+ for e := t.indexedItems.data.Front(); e != nil; e = e.Next() {
+ entry, ok := e.Value.(*indexedItemsEntry)
if !ok {
return removed, errors.New("Remove: could not parse e as a postIndexEntry")
}
@@ -105,7 +104,7 @@ func (t *timeline) RemoveAllBy(ctx context.Context, accountID string) (int, erro
}
}
for _, e := range removeIndexes {
- t.itemIndex.data.Remove(e)
+ t.indexedItems.data.Remove(e)
removed++
}