mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved file browser
This commit is contained in:
1 parent
8d11acd783
commit
93ec2ef425
10 files changed
+540
-204
No files matched your search
+46
-2
@@ -23,8 +23,8 @@ _TMP = tempfile.TemporaryDirectory()
|
||||
prefs._PREFS_PATH = Path(_TMP.name) / "userprefs.json"
|
||||
prefs._LEGACY_PREFS_PATH = Path(_TMP.name) / "absent.json"
|
||||
|
||||
from konduktor.core import registry # noqa: E402
|
||||
from konduktor.main import collection_options, fs_list, platforms # noqa: E402
|
||||
from konduktor.core import places, registry # noqa: E402
|
||||
from konduktor.main import collection_options, fs_list, fs_places, platforms # noqa: E402
|
||||
|
||||
failed = False
|
||||
|
||||
@@ -120,6 +120,50 @@ check("folders are listed for every platform",
|
||||
all({d.name for d in fs_list(str(root), p).dirs} == {"SomeDrive"}
|
||||
for p in (None, "traktor", "rekordbox", "onelibrary")))
|
||||
|
||||
print("== /api/fs/places: the browser's sidebar ==")
|
||||
rows = fs_places()
|
||||
check("there is always somewhere to go", len(rows) > 0)
|
||||
# A greyed-out Music folder on a machine that has none reads as breakage; its
|
||||
# absence reads as an accurate description of the machine.
|
||||
check("every place exists and is a directory",
|
||||
all(Path(r.path).is_dir() for r in rows),
|
||||
[r.path for r in rows if not Path(r.path).is_dir()])
|
||||
check("home is always offered", any(r.kind == "home" for r in rows))
|
||||
check("no duplicate paths", len({r.path for r in rows}) == len(rows))
|
||||
check("nothing is unnamed", all(r.name for r in rows))
|
||||
# macOS lists the startup disk in /Volumes next to real removable media, so a
|
||||
# Drives list that does not filter it leads with a path back to where you are.
|
||||
# Compared by DEVICE, because "Macintosh HD" is only the default name.
|
||||
check("the boot volume is not offered as a drive",
|
||||
not any(places.is_boot_volume(Path(r.path)) for r in rows if r.kind == "volume"),
|
||||
[r.path for r in rows if r.kind == "volume" and places.is_boot_volume(Path(r.path))])
|
||||
|
||||
lib_places = lambda plat: [r for r in fs_places(plat) if r.kind == "library"] # noqa: E731
|
||||
check("no library shortcut without a platform", lib_places(None) == [])
|
||||
for plat in ("traktor", "rekordbox"):
|
||||
found = registry.detect_for(plat)
|
||||
expected = {str(Path(c["path"]).parent) for c in found}
|
||||
got = {r.path for r in lib_places(plat)}
|
||||
# The shortcut is the folder CONTAINING the library: a place is somewhere
|
||||
# you navigate to, not something you pick.
|
||||
check(f"{plat}: shortcut points at the containing folder", got <= expected, f"{got} vs {expected}")
|
||||
if found:
|
||||
check(f"{plat}: the shortcut is offered", len(got) > 0)
|
||||
# A removable platform's libraries ARE the drives, which the Drives group
|
||||
# already lists — a second row for the same place would just be noise.
|
||||
check("no library shortcut for a removable platform", lib_places("onelibrary") == [])
|
||||
check("an unknown platform does not raise", isinstance(fs_places("nonesuch"), list))
|
||||
|
||||
print("== the mount scanner is shared, not duplicated ==")
|
||||
# It grew inside the OneLibrary adapter, because that is the platform whose
|
||||
# libraries are drives. "Where does this OS mount things" is not adapter
|
||||
# knowledge, though, and two scanners would drift.
|
||||
import konduktor.adapters.onelibrary.discovery as onelib_discovery # noqa: E402
|
||||
check("the adapter uses core's scanner, not its own",
|
||||
onelib_discovery._mount_points is places.mount_points)
|
||||
check("volumes() drops the boot volume, mount_points() does not",
|
||||
set(places.volumes()) <= set(places.mount_points()))
|
||||
|
||||
print("== a library may be a DIRECTORY, not just a file ==")
|
||||
drives = registry.detect_for("onelibrary")
|
||||
if drives:
|
||||
|
||||
Reference in new issue
Block a user