mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 04:05:08 +03:00
b1e28a8ae6
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>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
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")
|