feat: shorten paths that exceed the device's limit
Build and publish container / build (pull_request) Successful in 2m16s
Build and publish container / build (pull_request) Successful in 2m16s
Rockbox's MAX_PATH is 260, defined in firmware/include/fs_defines.h and used to size the directory entry buffer in dir.h. It bounds the path as the device sees it, so the directory the mirror is copied into spends part of the same budget; --device-prefix accounts for that and defaults to /Music. Over-budget paths are shortened from the deepest component outward. The track name carries the least navigational value and the artist directory the most, so the filename is cut first and the artist only if nothing else will serve. A shortened component keeps its extension and gains four hex digits of the original name: two long titles sharing a prefix cut to the same string otherwise, and a silent collision between two tracks is a worse outcome than an ugly filename. The result is stable. The same source always yields the same shortened name, so one pass does not rename what the last one wrote -- an unstable scheme would churn the whole mirror every six hours. A path too deeply nested to fit without reducing every component to nonsense is left alone and reported rather than mangled. Migration now tries more than one previous naming, because there is more than one. A mirror already running with --fat32-safe holds sanitised but unshortened paths, and matching only the original unsanitised name would have re-encoded every one of them instead of moving it. The checker gains the same two options, since it was measuring the mirror-relative path against a limit that applies to the device-absolute one, and so under-reported by the length of the destination directory.
This commit is contained in:
@@ -236,6 +236,26 @@ worse than no preview. A dry run also does not list the pre-rename files as
|
||||
orphans: nothing was moved, so they are still there, but they are what a real
|
||||
run would move rather than what it would delete.
|
||||
|
||||
### Path length
|
||||
|
||||
Rockbox's `MAX_PATH` is 260, from `firmware/include/fs_defines.h`, and it bounds
|
||||
the path *as the device sees it*. The directory the mirror is copied into comes
|
||||
out of the same budget, so `--device-prefix` (default `/Music`) is subtracted
|
||||
from `--max-path` to get what a mirror-relative path may spend.
|
||||
|
||||
Over-budget paths are shortened from the **deepest component outward**: the
|
||||
track name carries the least navigational value and the artist directory the
|
||||
most, so the filename goes first and the artist is touched only if nothing else
|
||||
will do. A shortened component keeps its extension and gains four hex digits of
|
||||
the original name — two long names sharing a prefix would otherwise cut to the
|
||||
same string, and a silent collision between two tracks is worse than an ugly
|
||||
filename.
|
||||
|
||||
The result is stable: the same source always produces the same shortened name,
|
||||
so a pass does not rename what the previous pass wrote. A path too deeply
|
||||
nested to fit without reducing every component to nonsense is left alone and
|
||||
reported instead.
|
||||
|
||||
### Album art
|
||||
|
||||
Rockbox looks for cover art **on the filesystem** — `cover.jpg`, `folder.jpg`
|
||||
|
||||
Reference in New Issue
Block a user