mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 04:32:24 -06:00
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
This commit is contained in:
parent
071eca20ce
commit
2dc9fc1626
713 changed files with 98694 additions and 22704 deletions
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue