Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't retrieve Tinderbox directory listing when timestamp is provided (#313) #679

Merged
37 changes: 19 additions & 18 deletions mozdownload/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,41 +972,42 @@ def get_build_info_for_index(self, build_index=None):
"""Get additional information for the build at the given index."""
url = urljoin(self.base_url, self.build_list_regex)

self.logger.info('Retrieving list of builds from %s' % url)
parser = self._create_directory_parser(url)
parser.entries = parser.filter(r'^\d+$')

if self.timestamp:
# If a timestamp is given, retrieve the folder with the timestamp
# as name
parser.entries = self.timestamp in parser.entries and \
[self.timestamp]
entries = [self.timestamp]
else:
self.logger.info('Retrieving list of builds from %s' % url)
parser = self._create_directory_parser(url)
parser.entries = parser.filter(r'^\d+$')

elif self.date:
# If date is given, retrieve the subset of builds on that date
parser.entries = list(filter(self.date_matches, parser.entries))
if self.date:
# If date is given, retrieve the subset of builds on that date
parser.entries = list(filter(self.date_matches, parser.entries))

if not parser.entries:
message = 'No builds have been found'
raise errors.NotFoundError(message, url)
if not parser.entries:
message = 'No builds have been found'
raise errors.NotFoundError(message, url)

self.show_matching_builds(parser.entries)
entries = parser.entries

self.show_matching_builds(entries)

# If no index has been given, set it to the last build of the day.
if build_index is None:
# Find the most recent non-empty entry.
build_index = len(parser.entries)
for build in reversed(parser.entries):
build_index = len(entries)
for build in reversed(entries):
build_index -= 1
if not build_index or self.is_build_dir(build):
break

if build_index >= len(parser.entries):
if build_index >= len(entries):
raise errors.NotFoundError('Specified build number has not been found ', url)

self.logger.info('Selected build: %s' % parser.entries[build_index])
self.logger.info('Selected build: %s' % entries[build_index])

return (parser.entries, build_index)
return (entries, build_index)

@property
def path_regex(self):
Expand Down
Loading