[chore] Duplicated media cleanup (#649)

* add migration to clean up duplicated media

* use /tmp/gotosocial for testrig storage path

* defer remove storage tempdir

* skip if not attached to status or status not found

* log errors at error level

* only log delete as else clause if successful

* just return nil on down

* reword delete logic a little bit

* check if storage base path is defined

* check for status id more thoroughly

* don't log error if just no rows

* go fmt

* break statusIDLoop when found

* break currentlyUsedLoop when found
This commit is contained in:
tobi
2022-06-14 18:00:57 +02:00
committed by GitHub
parent da2386bab1
commit 13e4bbdbfa
3 changed files with 171 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ package testrig
import (
"fmt"
"os"
"path"
"codeberg.org/gruf/go-store/kv"
"codeberg.org/gruf/go-store/storage"
@@ -94,6 +95,8 @@ func StandardStorageSetup(s *kv.KVStore, relativePath string) {
// StandardStorageTeardown deletes everything in storage so that it's clean for the next test
func StandardStorageTeardown(s *kv.KVStore) {
defer os.RemoveAll(path.Join(os.TempDir(), "gotosocial"))
iter, err := s.Iterator(nil)
if err != nil {
panic(err)