From a8085cf29a15da2de694388d90df59e60ad01057 Mon Sep 17 00:00:00 2001 From: rawdlite Date: Wed, 8 Jul 2015 00:23:15 +0200 Subject: [PATCH] file-browser: changd local_path to path in internal#path --- mopidy/files/library.py | 2 +- mopidy/internal/path.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mopidy/files/library.py b/mopidy/files/library.py index 47c58cda..42465fab 100644 --- a/mopidy/files/library.py +++ b/mopidy/files/library.py @@ -131,7 +131,7 @@ class FilesLibraryProvider(backend.LibraryProvider): res = False base_dirs = [mdir['path'] for mdir in self._media_dirs] for base_dir in base_dirs: - if path.is_local_path_inside_base_dir(local_path, base_dir): + if path.is_path_inside_base_dir(local_path, base_dir): res = True if not res: logger.warn('%s not inside any base_dir', local_path) diff --git a/mopidy/internal/path.py b/mopidy/internal/path.py index 7573dfd2..f56520f0 100644 --- a/mopidy/internal/path.py +++ b/mopidy/internal/path.py @@ -196,22 +196,22 @@ def find_mtimes(root, follow=False): return mtimes, errors -def is_local_path_inside_base_dir(local_path, base_path): - if local_path.endswith(os.sep): - raise ValueError('Local path %s cannot end with a path separator' - % local_path) +def is_path_inside_base_dir(path, base_path): + if path.endswith(os.sep): + raise ValueError('Path %s cannot end with a path separator' + % path) # Expand symlinks real_base_path = os.path.realpath(base_path) - real_local_path = os.path.realpath(local_path) + real_path = os.path.realpath(path) - if os.path.isfile(local_path): + if os.path.isfile(path): # Use dir of file for prefix comparision, so we don't accept # /tmp/foo.m3u as being inside /tmp/foo, simply because they have a # common prefix, /tmp/foo, which matches the base path, /tmp/foo. - real_local_path = os.path.dirname(real_local_path) + real_path = os.path.dirname(real_path) # Check if dir of file is the base path or a subdir - common_prefix = os.path.commonprefix([real_base_path, real_local_path]) + common_prefix = os.path.commonprefix([real_base_path, real_path]) return common_prefix == real_base_path