Skip to content

Commit

Permalink
Delete associated files from the storage
Browse files Browse the repository at this point in the history
closes #7316
  • Loading branch information
lubosmj authored and daviddavis committed Aug 20, 2020
1 parent c087828 commit f508d6b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGES/7316.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the django-cleanup handlers for removing files stored within FileField
2 changes: 2 additions & 0 deletions CHANGES/plugin_api/7316.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Enabled the automatic removal of files, which are stored in FileField, when a corresponding
model's delete() method is invoked
11 changes: 0 additions & 11 deletions pulpcore/app/models/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ def save(self, *args, **kwargs):
finally:
self.file.close()

def delete(self, *args, **kwargs):
"""
Deletes Model and the file associated with the Model
Args:
args (list): list of positional arguments for Model.delete()
kwargs (dict): dictionary of keyword arguments to pass to Model.delete()
"""
super().delete(*args, **kwargs)
self.file.delete(save=False)


class Artifact(HandleTempFilesMixin, BaseModel):
"""
Expand Down
11 changes: 0 additions & 11 deletions pulpcore/app/models/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ def append(self, chunk, offset, sha256=None):

self.chunks.create(offset=offset, size=len(chunk))

def delete(self, *args, **kwargs):
"""
Deletes Upload model and the file associated with the model
Args:
args (list): list of positional arguments for Model.delete()
kwargs (dict): dictionary of keyword arguments to pass to Model.delete()
"""
super().delete(*args, **kwargs)
self.file.delete(save=False)


class UploadChunk(BaseModel):
"""
Expand Down
2 changes: 2 additions & 0 deletions pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
"rest_framework",
# pulp core app
"pulpcore.app",
# the cleanup config has to be placed last
"django_cleanup.apps.CleanupConfig",
]

# Enumerate the installed Pulp plugins during the loading process for use in the status API
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ aiofiles
backoff
Django~=2.2.14 # LTS version, switch only if we have a compelling reason to
django-currentuser~=0.5.1
django-cleanup~=5.0.0
django-filter~=2.3.0
django-guardian~=2.3.0
django-import-export~=2.3.0
Expand Down

0 comments on commit f508d6b

Please sign in to comment.