Skip to content

Commit

Permalink
Delete quarantined content without deleting the DB record
Browse files Browse the repository at this point in the history
Fixes #197
  • Loading branch information
turt2live committed Sep 3, 2019
1 parent 381746d commit 46c53b4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion controllers/maintenance_controller/maintainance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,25 @@ func doPurge(media *types.Media, ctx context.Context, log *logrus.Entry) error {
}

metadataDb := storage.GetDatabase().GetMetadataStore(ctx, log)
err = metadataDb.ReserveMediaId(media.Origin, media.MediaId, "purged / deleted")

reserved, err := metadataDb.IsReserved(media.Origin, media.MediaId)
if err != nil {
return err
}

if !reserved {
err = metadataDb.ReserveMediaId(media.Origin, media.MediaId, "purged / deleted")
if err != nil {
return err
}
}

// Don't delete the media record itself if it is quarantined. If we delete it, the media
// becomes not-quarantined so we'll leave it and let it 404 in the datastores.
if media.Quarantined {
return nil
}

mediaDb := storage.GetDatabase().GetMediaStore(ctx, log)
err = mediaDb.Delete(media.Origin, media.MediaId)
if err != nil {
Expand Down

0 comments on commit 46c53b4

Please sign in to comment.