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"