From de4d75246c7db3b97c87da7f54db599beb999694 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 3 Jul 2022 12:18:59 +0200 Subject: [PATCH] [chore] Update pruneOneLocal to use ctx (#684) * update pruneOneLocal to use ctx * update test --- internal/media/pruneunusedlocal.go | 4 ++-- internal/media/pruneunusedlocal_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/media/pruneunusedlocal.go b/internal/media/pruneunusedlocal.go index 0c464e857..789583938 100644 --- a/internal/media/pruneunusedlocal.go +++ b/internal/media/pruneunusedlocal.go @@ -68,7 +68,7 @@ func (m *manager) pruneOneLocal(ctx context.Context, attachment *gtsmodel.MediaA if attachment.File.Path != "" { // delete the full size attachment from storage logrus.Tracef("pruneOneLocal: deleting %s", attachment.File.Path) - if err := m.storage.Delete(attachment.File.Path); err != nil && err != storage.ErrNotFound { + if err := m.storage.Delete(ctx, attachment.File.Path); err != nil && err != storage.ErrNotFound { return err } } @@ -76,7 +76,7 @@ func (m *manager) pruneOneLocal(ctx context.Context, attachment *gtsmodel.MediaA if attachment.Thumbnail.Path != "" { // delete the thumbnail from storage logrus.Tracef("pruneOneLocal: deleting %s", attachment.Thumbnail.Path) - if err := m.storage.Delete(attachment.Thumbnail.Path); err != nil && err != storage.ErrNotFound { + if err := m.storage.Delete(ctx, attachment.Thumbnail.Path); err != nil && err != storage.ErrNotFound { return err } } diff --git a/internal/media/pruneunusedlocal_test.go b/internal/media/pruneunusedlocal_test.go index 5f6bfbfba..976a6226c 100644 --- a/internal/media/pruneunusedlocal_test.go +++ b/internal/media/pruneunusedlocal_test.go @@ -61,7 +61,7 @@ func (suite *PruneUnusedLocalTestSuite) TestPruneOneNonExistent() { media, err := suite.db.GetAttachmentByID(ctx, testAttachment.ID) suite.NoError(err) suite.True(media.Cached) - err = suite.storage.Delete(media.File.Path) + err = suite.storage.Delete(ctx, media.File.Path) suite.NoError(err) // Now attempt to prune for item with db entry no file