diff options
author | 2022-06-30 12:22:10 +0200 | |
---|---|---|
committer | 2022-06-30 12:22:10 +0200 | |
commit | 9e7d022a06779a03e3eaaadad6cc33423f46892b (patch) | |
tree | 7c13c5af98fba382fc75c1dc195bdf0cc9cdd905 /internal/media/pruneremote.go | |
parent | [feature] Use default instance thumbnail if instance account header not set (... (diff) | |
download | gotosocial-9e7d022a06779a03e3eaaadad6cc33423f46892b.tar.xz |
[feature] Cleanup unattached local media (#680)
* add localUnattached db function
* add parseOlderThan util function
* add pruneunusedlocalattachments to media manager
* add unusedlocal pruning to schedule + admin call
* set number of days to keep as a const
* fix test
Diffstat (limited to 'internal/media/pruneremote.go')
-rw-r--r-- | internal/media/pruneremote.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/internal/media/pruneremote.go b/internal/media/pruneremote.go index f7b77d32e..a01995740 100644 --- a/internal/media/pruneremote.go +++ b/internal/media/pruneremote.go @@ -21,7 +21,6 @@ package media import ( "context" "fmt" - "time" "codeberg.org/gruf/go-store/storage" "github.com/sirupsen/logrus" @@ -32,15 +31,10 @@ import ( func (m *manager) PruneAllRemote(ctx context.Context, olderThanDays int) (int, error) { var totalPruned int - // convert days into a duration string - olderThanHoursString := fmt.Sprintf("%dh", olderThanDays*24) - // parse the duration string into a duration - olderThanHours, err := time.ParseDuration(olderThanHoursString) + olderThan, err := parseOlderThan(olderThanDays) if err != nil { - return totalPruned, fmt.Errorf("PruneAllRemote: %d", err) + return totalPruned, fmt.Errorf("PruneAllRemote: error parsing olderThanDays %d: %s", olderThanDays, err) } - // 'subtract' that from the time now to give our threshold - olderThan := time.Now().Add(-olderThanHours) logrus.Infof("PruneAllRemote: pruning media older than %s", olderThan) // select 20 attachments at a time and prune them |