Sphinx Search: don't skip indexing if one file fails
Changed the var names to make them more clear
@@ -1242,9 +1242,6 @@ class HTMLFile(ImportedFile):
Both lead to `foo/index.html`
https://github.com/rtfd/readthedocs.org/issues/5368
"""
- file_path = None
- storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
-
fjson_paths = []
basename = os.path.splitext(self.path)[0]
fjson_paths.append(basename + '.fjson')
@@ -1252,22 +1249,23 @@ class HTMLFile(ImportedFile):
new_basename = re.sub(r'\/index$', '', basename)
fjson_paths.append(new_basename + '.fjson')
+ storage = get_storage_class(settings.RTD_BUILD_MEDIA_STORAGE)()
storage_path = self.project.get_storage_path(
type_='json', version_slug=self.version.slug, include_file=False
)
- try:
for fjson_path in fjson_paths:
- file_path = storage.join(storage_path, fjson_path)
- if storage.exists(file_path):
- return process_file(file_path)
+ try:
+ fjson_storage_path = storage.join(storage_path, fjson_path)
+ if storage.exists(fjson_storage_path):
+ return process_file(fjson_storage_path)
except Exception:
log.warning(
'Unhandled exception during search processing file: %s',
- file_path,
+ fjson_path,
)
return {
- 'path': file_path,
+ 'path': self.path,
'title': '',
'sections': [],
'domain_data': {},
