From 5619f5cb78ed414f79488f9124a31ec48e3abb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20W=C3=BCrfl?= Date: Wed, 30 May 2018 17:59:32 +0200 Subject: [PATCH 1/3] Don't print double slashes Fixes #32 --- interface.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interface.py b/interface.py index e5b431a..296ea7f 100644 --- a/interface.py +++ b/interface.py @@ -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: From 32c78544f908e51723915348a226d351c636c0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20W=C3=BCrfl?= Date: Wed, 30 May 2018 19:14:32 +0200 Subject: [PATCH 2/3] utils.py: Fix not adding files correctly in some edge cases --- util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util.py b/util.py index 20c3e61..4007d2b 100644 --- a/util.py +++ b/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): @@ -66,7 +66,7 @@ class Dir(object): 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 From f8b2cc4529dd680ad03661a1c21d3c8be8edaff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20W=C3=BCrfl?= Date: Wed, 30 May 2018 19:17:17 +0200 Subject: [PATCH 3/3] utils.py: Remove unnecessary debugging print --- util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/util.py b/util.py index 4007d2b..1c4d4ed 100644 --- a/util.py +++ b/util.py @@ -60,7 +60,6 @@ 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 = []