Skip to content

Commit

Permalink
Ignore missing files when cleaning up media (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentynel committed Feb 6, 2023
1 parent 02767bf commit 6a6647d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/processing/media/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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))
}
}
Expand Down

0 comments on commit 6a6647d

Please sign in to comment.