Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion readthedocs/projects/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def clean_project_resources(project, version=None, version_slug=None):
- Artifacts from storage.
- Search indexes from ES.
- Imported files.
- Analytics data (``Pageview``s)

:param version: Version instance. If isn't given,
all resources of `project` will be deleted.
Expand Down Expand Up @@ -101,11 +102,13 @@ def clean_project_resources(project, version=None, version_slug=None):
version_slug=version_slug,
)

# Remove imported files
# Try to speed up deletion by calling delete directly
# We can try ``bulk_delete`` if this doesn't work.
if version:
version.imported_files.all().delete()
else:
project.imported_files.all().delete()
project.page_views.all().delete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary called when a project is deleted, it's also called from the admin. I'd put this under the delete method only (most of this data can be recovered, but pageview can't).



@app.task()
Expand Down