Ensure path replacement never contains trailing (back)slash

- Fixes #563
This commit is contained in:
croneter 2018-12-29 16:13:59 +01:00
parent 122bc56c31
commit 134b76cb09

View file

@ -5,6 +5,18 @@ from __future__ import absolute_import, division, unicode_literals
from .. import utils from .. import utils
def remove_trailing_slash(path):
"""
Removes trailing slashes or backslashes from path [unicode], and is NOT
dependent on os.path
"""
if '/' in path:
path = path[:-1] if path.endswith('/') else path
else:
path = path[:-1] if path.endswith('\\') else path
return path
class Sync(object): class Sync(object):
def __init__(self, entrypoint=False): def __init__(self, entrypoint=False):
if entrypoint: if entrypoint:
@ -36,14 +48,14 @@ class Sync(object):
self.remap_path = utils.settings('remapSMB') == 'true' self.remap_path = utils.settings('remapSMB') == 'true'
self.force_transcode_pix = utils.settings('force_transcode_pix') == 'true' self.force_transcode_pix = utils.settings('force_transcode_pix') == 'true'
# Mappings for REMAP_PATH: # Mappings for REMAP_PATH:
self.remapSMBmovieOrg = utils.settings('remapSMBmovieOrg') self.remapSMBmovieOrg = remove_trailing_slash(utils.settings('remapSMBmovieOrg'))
self.remapSMBmovieNew = utils.settings('remapSMBmovieNew') self.remapSMBmovieNew = remove_trailing_slash(utils.settings('remapSMBmovieNew'))
self.remapSMBtvOrg = utils.settings('remapSMBtvOrg') self.remapSMBtvOrg = remove_trailing_slash(utils.settings('remapSMBtvOrg'))
self.remapSMBtvNew = utils.settings('remapSMBtvNew') self.remapSMBtvNew = remove_trailing_slash(utils.settings('remapSMBtvNew'))
self.remapSMBmusicOrg = utils.settings('remapSMBmusicOrg') self.remapSMBmusicOrg = remove_trailing_slash(utils.settings('remapSMBmusicOrg'))
self.remapSMBmusicNew = utils.settings('remapSMBmusicNew') self.remapSMBmusicNew = remove_trailing_slash(utils.settings('remapSMBmusicNew'))
self.remapSMBphotoOrg = utils.settings('remapSMBphotoOrg') self.remapSMBphotoOrg = remove_trailing_slash(utils.settings('remapSMBphotoOrg'))
self.remapSMBphotoNew = utils.settings('remapSMBphotoNew') self.remapSMBphotoNew = remove_trailing_slash(utils.settings('remapSMBphotoNew'))
# Escape path? # Escape path?
self.escape_path = utils.settings('escapePath') == 'true' self.escape_path = utils.settings('escapePath') == 'true'
# Shall we replace custom user ratings with the number of versions available? # Shall we replace custom user ratings with the number of versions available?