Merge pull request #50 from BafDyce/fix-double-slashes
Remove double slashes from file paths (and other improvements in utils.py)
This commit is contained in:
commit
535591c1ff
@ -84,7 +84,13 @@ def index():
|
||||
files = music_library.get_files_recursively(folder)
|
||||
else:
|
||||
files = music_library.get_files(folder)
|
||||
files = list(map(lambda file: ('file', folder + '/' + file), files))
|
||||
files = list(map(
|
||||
lambda file: (
|
||||
'file',
|
||||
os.path.join(folder, file)
|
||||
),
|
||||
files
|
||||
))
|
||||
print('Adding to playlist: ', files)
|
||||
var.playlist.extend(files)
|
||||
elif 'delete_music' in request.form:
|
||||
|
5
util.py
5
util.py
@ -9,7 +9,7 @@ import zipfile
|
||||
def get_recursive_filelist_sorted(path):
|
||||
filelist = []
|
||||
for root, dirs, files in os.walk(path):
|
||||
relroot = root.replace(path, '')
|
||||
relroot = root.replace(path, '', 1)
|
||||
if relroot != '' and relroot in var.config.get('bot', 'ignored_folders'):
|
||||
continue
|
||||
if len(relroot):
|
||||
@ -60,13 +60,12 @@ class Dir(object):
|
||||
def __init__(self, path):
|
||||
self.name = os.path.basename(path.strip('/'))
|
||||
self.fullpath = path
|
||||
print(self.name, self.fullpath)
|
||||
self.subdirs = {}
|
||||
self.files = []
|
||||
|
||||
def add_file(self, file):
|
||||
if file.startswith(self.name + '/'):
|
||||
file = file.replace(self.name + '/', '')
|
||||
file = file.replace(self.name + '/', '', 1)
|
||||
|
||||
if '/' in file:
|
||||
# This file is in a subdir
|
||||
|
Loading…
x
Reference in New Issue
Block a user