diff options
author | 2021-08-25 15:34:33 +0200 | |
---|---|---|
committer | 2021-08-25 15:34:33 +0200 | |
commit | 2dc9fc1626507bb54417fc4a1920b847cafb27a2 (patch) | |
tree | 4ddeac479b923db38090aac8bd9209f3646851c1 /internal/processing/media/delete.go | |
parent | Manually approves followers (#146) (diff) | |
download | gotosocial-2dc9fc1626507bb54417fc4a1920b847cafb27a2.tar.xz |
Pg to bun (#148)
* start moving to bun
* changing more stuff
* more
* and yet more
* tests passing
* seems stable now
* more big changes
* small fix
* little fixes
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)) } |