From ce8c934436cb969e99145d9eb176ec15e826f5de Mon Sep 17 00:00:00 2001 From: everbarry Date: Fri, 10 Apr 2026 13:37:17 +0200 Subject: [PATCH] fix bug --- main.py | 15 +++++++++++++-- uv.lock | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index e158997..77a9bf0 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ import sys from contextlib import contextmanager from functools import cmp_to_key -__title__ = "KeyJ's iPod shuffle Database Builder" +__title__ = "iPod shuffle Database Builder" # by Sylvain __version__ = "1.0-rc1" KNOWN_PROPS = frozenset( ("filename", "size", "ignore", "type", "shuffle", "reuse", "bookmark") @@ -240,6 +240,17 @@ class ShuffleRebuild: ka, kb = cls._key_repr(a), cls._key_repr(b) return (ka > kb) - (ka < kb) + @classmethod + def _cmp_file_entry(cls, a, b) -> int: + c = (a[0] > b[0]) - (a[0] < b[0]) + if c: + return c + c = cls._cmp_sort_key(a[1], b[1]) + if c: + return c + pa, pb = a[2], b[2] + return (pa > pb) - (pa < pb) + def _file_entry(self, path: str, name: str, prefix: str = ""): if not name or name[0] == ".": return None @@ -302,7 +313,7 @@ class ShuffleRebuild: ) except OSError: pass - files.sort(key=cmp_to_key(self._cmp_sort_key)) + files.sort(key=cmp_to_key(self._cmp_file_entry)) nfiles = sum(1 for x in files if x[0]) if nfiles: self.domains.append([]) diff --git a/uv.lock b/uv.lock index b05c2d1..86a48e9 100644 --- a/uv.lock +++ b/uv.lock @@ -4,7 +4,7 @@ requires-python = ">=3.14" [[package]] name = "ipodutils" -version = "0.1.0" +version = "0.1.1" source = { editable = "." } [package.dev-dependencies]