Skip to content

Commit 26c9393

Browse files
committed
Remove unneeded methods to get local paths
1 parent 4338b99 commit 26c9393

File tree

3 files changed

+1
-72
lines changed

3 files changed

+1
-72
lines changed

readthedocs/builds/models.py

-17
Original file line numberDiff line numberDiff line change
@@ -396,23 +396,6 @@ def get_build_path(self):
396396
return path
397397
return None
398398

399-
def get_artifact_paths(self):
400-
"""
401-
Return a list of all production artifacts/media path for this version.
402-
403-
:rtype: list
404-
"""
405-
paths = []
406-
407-
for type_ in ('pdf', 'epub', 'htmlzip'):
408-
paths.append(
409-
self.project
410-
.get_production_media_path(type_=type_, version_slug=self.slug),
411-
)
412-
paths.append(self.project.rtd_build_path(version=self.slug))
413-
414-
return paths
415-
416399
def get_storage_paths(self):
417400
"""
418401
Return a list of all build artifact storage paths for this version.

readthedocs/projects/models.py

-38
Original file line numberDiff line numberDiff line change
@@ -539,38 +539,6 @@ def get_storage_path(
539539
)
540540
return folder_path
541541

542-
def get_production_media_path(self, type_, version_slug, include_file=True):
543-
"""
544-
Used to see if these files exist so we can offer them for download.
545-
546-
:param type_: Media content type, ie - 'pdf', 'zip'
547-
:param version_slug: Project version slug for lookup
548-
:param include_file: Include file name in return
549-
:type include_file: bool
550-
551-
:returns: Full path to media file or path
552-
"""
553-
if settings.DEFAULT_PRIVACY_LEVEL == 'public' or settings.DEBUG:
554-
path = os.path.join(
555-
settings.MEDIA_ROOT,
556-
type_,
557-
self.slug,
558-
version_slug,
559-
)
560-
else:
561-
path = os.path.join(
562-
settings.PRODUCTION_MEDIA_ARTIFACTS,
563-
type_,
564-
self.slug,
565-
version_slug,
566-
)
567-
if include_file:
568-
path = os.path.join(
569-
path,
570-
'{}.{}'.format(self.slug, type_.replace('htmlzip', 'zip')),
571-
)
572-
return path
573-
574542
def get_production_media_url(self, type_, version_slug):
575543
"""Get the URL for downloading a specific media file."""
576544
# Use project domain for full path --same domain as docs
@@ -740,12 +708,6 @@ def has_good_build(self):
740708
return self.builds(manager=INTERNAL).filter(success=True).exists()
741709

742710
def has_media(self, type_, version_slug=LATEST, version_type=None):
743-
path = self.get_production_media_path(
744-
type_=type_, version_slug=version_slug
745-
)
746-
if os.path.exists(path):
747-
return True
748-
749711
storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
750712
storage_path = self.get_storage_path(
751713
type_=type_, version_slug=version_slug,

readthedocs/rtd_tests/tests/test_celery.py

+1-17
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,6 @@ def test_remove_dirs(self):
8282
self.assertTrue(result.successful())
8383
self.assertFalse(exists(directory))
8484

85-
def test_clear_artifacts(self):
86-
version = self.project.versions.all()[0]
87-
directory = self.project.get_production_media_path(type_='pdf', version_slug=version.slug)
88-
os.makedirs(directory)
89-
self.assertTrue(exists(directory))
90-
result = tasks.remove_dirs.delay(paths=version.get_artifact_paths())
91-
self.assertTrue(result.successful())
92-
self.assertFalse(exists(directory))
93-
94-
directory = version.project.rtd_build_path(version=version.slug)
95-
os.makedirs(directory)
96-
self.assertTrue(exists(directory))
97-
result = tasks.remove_dirs.delay(paths=version.get_artifact_paths())
98-
self.assertTrue(result.successful())
99-
self.assertFalse(exists(directory))
100-
10185
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_python_environment', new=MagicMock)
10286
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.build_docs', new=MagicMock)
10387
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_vcs', new=MagicMock)
@@ -164,7 +148,7 @@ def test_update_docs_unexpected_build_exception(self, mock_build_docs):
164148
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_vcs')
165149
def test_no_notification_on_version_locked_error(self, mock_setup_vcs, mock_send_notifications):
166150
mock_setup_vcs.side_effect = VersionLockedError()
167-
151+
168152
version = self.project.versions.first()
169153

170154
build = get(

0 commit comments

Comments
 (0)