From 1eb7de2a1a42064ac6caf56fea8b41e08fff2ea9 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 18 Jun 2026 14:52:12 +0200 Subject: [PATCH] fix: duplicate-tab folder is a sibling, not a child, when source ends in / MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ".../AlexisCrystal/" + "_copy" was producing ".../AlexisCrystal/_copy"; rstrip the trailing separator first → ".../AlexisCrystal_copy". Regression test uses a trailing-slash source folder. Co-Authored-By: Claude Fable 5 --- main.py | 4 +++- tests/test_ui_structure.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index b6643a3..4e17005 100755 --- a/main.py +++ b/main.py @@ -4999,7 +4999,9 @@ class MainWindow(QMainWindow): select=True, ) src_folder = getattr(src, "_dest_folder", "") - pw._dest_folder = (src_folder + "_copy") if src_folder else "" + # rstrip the trailing separator so ".../AlexisCrystal/" + "_copy" becomes + # a sibling ".../AlexisCrystal_copy", not a child ".../AlexisCrystal/_copy". + pw._dest_folder = (src_folder.rstrip("/" + os.sep) + "_copy") if src_folder else "" pw._tab_folder = getattr(src, "_tab_folder", False) self._sync_folder_field_to_tab() self._save_playlist_tabs() diff --git a/tests/test_ui_structure.py b/tests/test_ui_structure.py index 97cd9bd..792f82d 100644 --- a/tests/test_ui_structure.py +++ b/tests/test_ui_structure.py @@ -127,7 +127,7 @@ def test_duplicate_tab(win): try: src = win._pws[0] src._label = "AlexisCrystal" - src._dest_folder = "/data/alexis" + src._dest_folder = "/data/alexis/" # trailing slash, like real folders n_before = len(win._pws) win._on_duplicate_tab(win._playlist_tabs.indexOf(src)) finally: @@ -135,4 +135,5 @@ def test_duplicate_tab(win): assert len(win._pws) == n_before + 1 dup = win._pws[-1] assert dup._label == "AlexisCrystal copy" + # sibling, not a child: ".../alexis/" -> ".../alexis_copy" (not ".../alexis/_copy") assert dup._dest_folder == "/data/alexis_copy"