Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to deletion of attachment and attachment content #145

Merged
merged 3 commits into from
Jan 31, 2017

Conversation

Azquelt
Copy link
Member

@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.
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.
@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