From 6a6647d68baaefbd19ef6010c889ebd7980667b1 Mon Sep 17 00:00:00 2001 From: Sam Lade Date: Mon, 6 Feb 2023 14:58:54 +0000 Subject: [PATCH] Ignore missing files when cleaning up media (#1435) --- internal/processing/media/delete.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/processing/media/delete.go b/internal/processing/media/delete.go index 45c218397..c0f8aa948 100644 --- a/internal/processing/media/delete.go +++ b/internal/processing/media/delete.go @@ -2,9 +2,11 @@ package media import ( "context" + "errors" "fmt" "strings" + "codeberg.org/gruf/go-store/v2/storage" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" ) @@ -24,14 +26,14 @@ func (p *processor) Delete(ctx context.Context, mediaAttachmentID string) gtserr // delete the thumbnail from storage if attachment.Thumbnail.Path != "" { - if err := p.storage.Delete(ctx, attachment.Thumbnail.Path); err != nil { + if err := p.storage.Delete(ctx, attachment.Thumbnail.Path); err != nil && !errors.Is(err, storage.ErrNotFound) { errs = append(errs, fmt.Sprintf("remove thumbnail at path %s: %s", attachment.Thumbnail.Path, err)) } } // delete the file from storage if attachment.File.Path != "" { - if err := p.storage.Delete(ctx, attachment.File.Path); err != nil { + if err := p.storage.Delete(ctx, attachment.File.Path); err != nil && !errors.Is(err, storage.ErrNotFound) { errs = append(errs, fmt.Sprintf("remove file at path %s: %s", attachment.File.Path, err)) } }