file-browser: changd local_path to path in internal#path

This commit is contained in:
rawdlite 2015-07-08 00:23:15 +02:00
parent d8e0099ff4
commit a8085cf29a
2 changed files with 9 additions and 9 deletions

View File

@ -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)

View File

@ -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