diff --git a/readthedocs/builds/models.py b/readthedocs/builds/models.py index 14a3b1b59cc..dbedd683142 100644 --- a/readthedocs/builds/models.py +++ b/readthedocs/builds/models.py @@ -412,21 +412,6 @@ def get_storage_environment_cache_path(self): """Return the path of the cached environment tar file.""" return build_environment_storage.join(self.project.slug, f'{self.slug}.tar') - def clean_build_path(self): - """ - Clean build path for project version. - - Ensure build path is clean for project version. Used to ensure stale - build checkouts for each project version are removed. - """ - try: - path = self.get_build_path() - if path is not None: - log.debug('Removing build path for project.', path=path, project_slug=self.slug) - rmtree(path) - except OSError: - log.exception('Build path cleanup failed') - def get_github_url( self, docroot, diff --git a/readthedocs/core/management/commands/clean_builds.py b/readthedocs/core/management/commands/clean_builds.py deleted file mode 100644 index c49820cee12..00000000000 --- a/readthedocs/core/management/commands/clean_builds.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Clean up stable build paths per project version.""" - -import structlog -from datetime import timedelta - -from django.core.management.base import BaseCommand -from django.db.models import Max -from django.utils import timezone - -from readthedocs.builds.models import Build, Version - - -log = structlog.get_logger(__name__) - - -class Command(BaseCommand): - - help = __doc__ - - def add_arguments(self, parser): - parser.add_argument( - '--days', - dest='days', - type=int, - default=365, - help='Find builds older than DAYS days, default: 365', - ) - - parser.add_argument( - '--dryrun', - action='store_true', - dest='dryrun', - help='Perform dry run on build cleanup', - ) - - def handle(self, *args, **options): - """Find stale builds and remove build paths.""" - max_date = timezone.now() - timedelta(days=options['days']) - queryset = ( - Build.objects.values('project', 'version').annotate( - max_date=Max('date'), - ).filter(max_date__lt=max_date).order_by('-max_date') - ) - for build in queryset: - try: - # Get version from build version id, perform sanity check on - # latest build date - version = Version.objects.get(id=build['version']) - latest_build = version.builds.latest('date') - if latest_build.date > max_date: - log.warning( - 'Latest build is newer.', - build_id=latest_build.pk, - date=latest_build.date, - max_date=max_date, - ) - path = version.get_build_path() - if path is not None: - log.info( - 'Found stale build path for version at path, last used on date.', - version_slug=version.slug, - path=path, - date=latest_build.date, - ) - if not options['dryrun']: - version.clean_build_path() - except Version.DoesNotExist: - pass diff --git a/readthedocs/core/management/commands/pull.py b/readthedocs/core/management/commands/pull.py deleted file mode 100644 index 93551e034d1..00000000000 --- a/readthedocs/core/management/commands/pull.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Trigger build for project slug.""" - -import structlog - -from django.core.management.base import LabelCommand - -from readthedocs.builds.constants import LATEST -from readthedocs.projects import tasks, utils - - -log = structlog.get_logger(__name__) - - -class Command(LabelCommand): - - help = __doc__ - - def handle_label(self, label, **options): - version = utils.version_from_slug(label, LATEST) - tasks.sync_repository_task(version.pk) diff --git a/readthedocs/core/management/commands/update_versions.py b/readthedocs/core/management/commands/update_versions.py deleted file mode 100644 index 6456accc430..00000000000 --- a/readthedocs/core/management/commands/update_versions.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Rebuild documentation for all projects.""" - -from django.core.management.base import BaseCommand - -from readthedocs.builds.models import Version -from readthedocs.projects.tasks import update_docs_task - - -class Command(BaseCommand): - - help = __doc__ - - def handle(self, *args, **options): - for version in Version.internal.filter(active=True, built=False): - # pylint: disable=no-value-for-parameter - update_docs_task( - version.pk, - record=False, - )