Skip to content

Commit

Permalink
Merge pull request #1261 from jodal/fix/1260-dont-scan-on-file-browsing
Browse files Browse the repository at this point in the history
file: Don't scan files on browsing
  • Loading branch information
adamcik committed Aug 21, 2015
2 parents eee851f + baa2cc7 commit 3e7e160
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Bug fix release.
with a limited set of environment variables. (Fixes: :issue:`1249`, PR:
:issue:`1255`)

- File: When browsing files, we no longer scan the files to check if they're
playable. This makes browsing of the file hierarchy instant for HTTP clients,
which do no scanning of the files' metadata, and a bit faster for MPD
clients, which no longer scan the files twice. (Fixes: :issue:`1260`, PR:
:issue:`1261`)

- Audio: Fix timeout handling in scanner. This regression caused timeouts to
expire before it should, causing scans to fail.

Expand Down
14 changes: 1 addition & 13 deletions mopidy/file/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def browse(self, uri):
name = dir_entry.decode(FS_ENCODING, 'replace')
if os.path.isdir(child_path):
result.append(models.Ref.directory(name=name, uri=uri))
elif os.path.isfile(child_path) and self._is_audio_file(uri):
elif os.path.isfile(child_path):
result.append(models.Ref.track(name=name, uri=uri))

result.sort(key=operator.attrgetter('name'))
Expand Down Expand Up @@ -134,18 +134,6 @@ def _get_media_dirs_refs(self):
name=media_dir['name'],
uri=path.path_to_uri(media_dir['path']))

def _is_audio_file(self, uri):
try:
result = self._scanner.scan(uri)
if result.playable:
logger.debug('Playable file: %s', result.uri)
else:
logger.debug('Unplayable file: %s (not audio)', result.uri)
return result.playable
except exceptions.ScannerError as e:
logger.debug('Unplayable file: %s (%s)', uri, e)
return False

def _is_in_basedir(self, local_path):
return any(
path.is_path_inside_base_dir(local_path, media_dir['path'])
Expand Down

0 comments on commit 3e7e160

Please sign in to comment.