Skip to content

Commit

Permalink
Source/Collection version delete to correctly delete all cached expor…
Browse files Browse the repository at this point in the history
…t files from S3
  • Loading branch information
snyaggarwal committed Apr 26, 2021
1 parent 43aadbf commit 6654553
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/common/models.py
Expand Up @@ -420,7 +420,7 @@ def delete(self, using=None, keep_parents=False):
if self.is_content_privately_referred():
raise ValidationError(dict(detail=CONTENT_REFERRED_PRIVATELY.format(self.mnemonic)))

generic_export_path = self.generic_export_path()
generic_export_path = self.generic_export_path(suffix=None)

if self.is_head:
self.versions.exclude(id=self.id).delete()
Expand Down
4 changes: 1 addition & 3 deletions core/common/services.py
Expand Up @@ -136,9 +136,7 @@ def exists(cls, key):
def __fetch_keys(cls, prefix='/', delimiter='/'): # pragma: no cover
prefix = prefix[1:] if prefix.startswith(delimiter) else prefix
s3_resource = cls.resource()
objects = s3_resource.meta.client.list_objects(
Bucket=settings.AWS_STORAGE_BUCKET_NAME, Prefix=prefix
)
objects = s3_resource.meta.client.list_objects(Bucket=settings.AWS_STORAGE_BUCKET_NAME, Prefix=prefix)
return [{'Key': k} for k in [obj['Key'] for obj in objects.get('Contents', [])]]

@classmethod
Expand Down

0 comments on commit 6654553

Please sign in to comment.