diff options
Diffstat (limited to 'internal/processing/media/delete.go')
-rw-r--r-- | internal/processing/media/delete.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/internal/processing/media/delete.go b/internal/processing/media/delete.go index b5ea8c806..281ddba03 100644 --- a/internal/processing/media/delete.go +++ b/internal/processing/media/delete.go @@ -1,17 +1,17 @@ package media import ( + "context" "fmt" "strings" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" - "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" ) -func (p *processor) Delete(mediaAttachmentID string) gtserror.WithCode { - a := >smodel.MediaAttachment{} - if err := p.db.GetByID(mediaAttachmentID, a); err != nil { +func (p *processor) Delete(ctx context.Context, mediaAttachmentID string) gtserror.WithCode { + attachment, err := p.db.GetAttachmentByID(ctx, mediaAttachmentID) + if err != nil { if err == db.ErrNoEntries { // attachment already gone return nil @@ -23,21 +23,21 @@ func (p *processor) Delete(mediaAttachmentID string) gtserror.WithCode { errs := []string{} // delete the thumbnail from storage - if a.Thumbnail.Path != "" { - if err := p.storage.RemoveFileAt(a.Thumbnail.Path); err != nil { - errs = append(errs, fmt.Sprintf("remove thumbnail at path %s: %s", a.Thumbnail.Path, err)) + if attachment.Thumbnail.Path != "" { + if err := p.storage.RemoveFileAt(attachment.Thumbnail.Path); err != nil { + errs = append(errs, fmt.Sprintf("remove thumbnail at path %s: %s", attachment.Thumbnail.Path, err)) } } // delete the file from storage - if a.File.Path != "" { - if err := p.storage.RemoveFileAt(a.File.Path); err != nil { - errs = append(errs, fmt.Sprintf("remove file at path %s: %s", a.File.Path, err)) + if attachment.File.Path != "" { + if err := p.storage.RemoveFileAt(attachment.File.Path); err != nil { + errs = append(errs, fmt.Sprintf("remove file at path %s: %s", attachment.File.Path, err)) } } // delete the attachment - if err := p.db.DeleteByID(mediaAttachmentID, a); err != nil { + if err := p.db.DeleteByID(ctx, mediaAttachmentID, attachment); err != nil { if err != db.ErrNoEntries { errs = append(errs, fmt.Sprintf("remove attachment: %s", err)) } |