Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/crutchcorn/moonsound. A Tauri-powered music player with high-res audio quality.
Something went wrong. Try again.
DB Architecture #
Song Identification #
In Moonsound, we have a challenge with identifying songs:
- A song's filesystem path (
fsPath) can change when the user moves the file - A song's hash (IE
md5) is expensive to compute and is likely to change - Using the last modified time (
mtime) and size of the file (size) isn't reliable because tag metadata is often stored in the file itself
However, there is a bit of a silver bullet (with two major asterisks):
These act as a reference point for each file in the filesystem for POSIX systems. Each file has a unique ID that persists for each file on the device, even across file moves and content modifications. Even Windows has similar equivilant APIs.
However, the two asterisks are:
- The
inodeneeds to be tracked alongsidedevice_id, which is drive (partition?) specific. Meaning that if the user changes from, IE, C:// to D:// the files will lose theinodenumber - Some programs, like song metadata editors, will often write to a
/tmplocation and then replace the original song with the new file; which itself will have a newinodefile.
Long-story-short, we can track the inode number as a heuristic of how to identify a song that has changed.
We can use this package to track inode numbers:
https://docs.rs/file-id/latest/file_id/
File Watching #
See a list of known problems with file watching, their docs are better than mine will be: https://docs.rs/notify/latest/notify/#known-problems