[feature] Media cleanup endpoint (#560)

Adds an admin endpoint to trigger a remote media cleanup.

Fixed #348

Signed-off-by: Sashanoraa <sasha@noraa.gay>
This commit is contained in:
Sashanoraa 2022-05-15 08:52:46 -04:00 committed by GitHub
commit 6e947ff266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 321 additions and 5 deletions

View file

@ -39,7 +39,7 @@ func (suite *PruneRemoteTestSuite) TestPruneRemote() {
totalPruned, err := suite.manager.PruneRemote(context.Background(), 1)
suite.NoError(err)
suite.Equal(1, totalPruned)
suite.Equal(2, totalPruned)
prunedAttachment, err := suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
suite.NoError(err)
@ -51,7 +51,7 @@ func (suite *PruneRemoteTestSuite) TestPruneRemote() {
func (suite *PruneRemoteTestSuite) TestPruneRemoteTwice() {
totalPruned, err := suite.manager.PruneRemote(context.Background(), 1)
suite.NoError(err)
suite.Equal(1, totalPruned)
suite.Equal(2, totalPruned)
// final prune should prune nothing, since the first prune already happened
totalPrunedAgain, err := suite.manager.PruneRemote(context.Background(), 1)
@ -65,7 +65,7 @@ func (suite *PruneRemoteTestSuite) TestPruneAndRecache() {
totalPruned, err := suite.manager.PruneRemote(ctx, 1)
suite.NoError(err)
suite.Equal(1, totalPruned)
suite.Equal(2, totalPruned)
// media should no longer be stored
_, err = suite.storage.Get(testAttachment.File.Path)
@ -118,7 +118,7 @@ func (suite *PruneRemoteTestSuite) TestPruneOneNonExistent() {
// Now attempt to prune remote for item with db entry no file
totalPruned, err := suite.manager.PruneRemote(ctx, 1)
suite.NoError(err)
suite.Equal(1, totalPruned)
suite.Equal(2, totalPruned)
}
func TestPruneRemoteTestSuite(t *testing.T) {