mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 04:05:08 +03:00
✨ Added match_existing_path_case option (#335)
When enabled, existing path components are reused even if Tidal returns different casing. This avoids creating separate paths on case-sensitive filesystems that would conflict later when moved to case-insensitive systems. For example, if "FooBar" already exists and the API returns "foobar", downloads will continue under "FooBar". Co-authored-by: Piotr Karbowski <git.throwaway941@simplelogin.com>
This commit is contained in:
@@ -38,6 +38,20 @@ def test_valid_config_file(tmp_path: Path):
|
||||
assert cfg.download.threads_count == 8
|
||||
|
||||
|
||||
def test_match_existing_path_case_config(tmp_path: Path):
|
||||
cfg_file = write_config(
|
||||
tmp_path,
|
||||
"""
|
||||
[download]
|
||||
match_existing_path_case = true
|
||||
""",
|
||||
)
|
||||
|
||||
cfg = load_config_file(cfg_file)
|
||||
|
||||
assert cfg.download.match_existing_path_case is True
|
||||
|
||||
|
||||
def test_invalid_type_raises(tmp_path: Path):
|
||||
cfg_file = write_config(
|
||||
tmp_path,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from tiddl.cli.utils.path import resolve_existing_path_case
|
||||
|
||||
|
||||
def test_resolve_existing_path_case_reuses_existing_directories(tmp_path: Path):
|
||||
existing_album = tmp_path / "FooBar" / "[2024.01.02] Album"
|
||||
existing_album.mkdir(parents=True)
|
||||
|
||||
path = resolve_existing_path_case(
|
||||
tmp_path,
|
||||
Path("foobar") / "[2024.01.02] album" / "01 - Track.flac",
|
||||
)
|
||||
|
||||
assert path == existing_album / "01 - Track.flac"
|
||||
|
||||
|
||||
def test_resolve_existing_path_case_reuses_existing_file(tmp_path: Path):
|
||||
existing_file = tmp_path / "FooBar" / "01 - Track.flac"
|
||||
existing_file.parent.mkdir()
|
||||
existing_file.touch()
|
||||
|
||||
path = resolve_existing_path_case(tmp_path, Path("foobar") / "01 - track.flac")
|
||||
|
||||
assert path == existing_file
|
||||
|
||||
|
||||
def test_resolve_existing_path_case_keeps_new_components(tmp_path: Path):
|
||||
path = resolve_existing_path_case(tmp_path, Path("FooBar") / "New Album")
|
||||
|
||||
assert path == tmp_path / "FooBar" / "New Album"
|
||||
|
||||
|
||||
def test_resolve_existing_path_case_rejects_absolute_path(tmp_path: Path):
|
||||
with pytest.raises(ValueError, match="relative_path"):
|
||||
resolve_existing_path_case(tmp_path, tmp_path / "FooBar")
|
||||
Reference in New Issue
Block a user