Skip to content

Conversation

@Azquelt
Copy link
Contributor

@Azquelt Azquelt commented Jan 30, 2017

This change fixes two problems

  • When an asset was deleted, the associated attachments were not being deleted
  • When an attachment with content was deleted, the associated content was not being deleted

If assets are regularly added and removed from the repository, this leads to a build up of orphaned attachments and attachment content in the database which can only be removed manually.

Also update existing tests to use the new method.
@Azquelt Azquelt force-pushed the delete-attachment-content branch from b0d3548 to b778496 Compare January 31, 2017 13:23
Add test that deleting asset deletes attachments

Also add a check to ensure there are no attachments remaining in the
database after clearing the repository at the end of each test.

Note that previously, the code was trying to retrieve the attachments to
delete by calling asset.getAttachments(). However, this doesn't work
because the previous call to retrieveAssets() does not populate the
asset object with its attachments. This is by design because we don't
always want to return the attachments associated with an asset.
Make sure that attachment content is actually removed from the mongo
database when the attachment is deleted.

Add check to ensure attachment content is deleted

Change Persistor.deleteAttachmentContent to take the gridFsId rather
than the attachment id. This matches the signature for
retrieveAttachmentMetadata and the difference is probably why the bug
wasn't originally spotted.

PersistenceBean.deleteAttachmentContent now actually does what it says
it does.

AssetServiceLayer change to match the new semantics of
deleteAttachmentContent.

RepositoryContext change to check for orphaned attachment content when
cleaning repository between tests.
@Azquelt Azquelt force-pushed the delete-attachment-content branch from b778496 to 9a5ed96 Compare January 31, 2017 13:27
@idlewis idlewis merged commit 30ace58 into WASdev:master Jan 31, 2017
@Azquelt Azquelt deleted the delete-attachment-content branch February 8, 2017 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants