-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
264 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Architecture | ||
|
||
Rosé has a simple uni-directional looping architecture. | ||
|
||
```mermaid | ||
flowchart BT | ||
S[Source Files] | ||
C[Read Cache] | ||
M[Metadata Tooling] | ||
V[Virtual Filesystem] | ||
S -->|Populates| C | ||
M -->|Reads| C | ||
M -->|Writes| S | ||
V -->|Writes| S | ||
V -->|Reads| C | ||
``` | ||
|
||
1. The source audio files, playlist files, and collage files are single sources | ||
of truth. All writes are made directly to the sources files. | ||
2. The read cache is transient and deterministically derived from source | ||
files. It can always be deleted and fully recreated from source files. It | ||
updates in response to changes in the source files. | ||
3. The virtual filesystem uses the read cache for performance. All writes made | ||
via the virtual filesystem are made to the Source Files, which in turn | ||
refreshes the read cache. | ||
4. The metadata tooling uses the read cache for performance, but always writes | ||
to the source files directly, which in turn refreshes the read cache. | ||
|
||
This architecture takes care to ensure that there is a single source of truth | ||
and uni-directional mutations. This means that Rosé and the source files always | ||
have the same metadata. If the source files change, `rose cache update` is | ||
guaranteed to rebuild the cache such that it fully matches the source files. | ||
And if `rose cache watch` is running, the cache updates should happen | ||
automatically. | ||
|
||
This has some nice consequences: | ||
|
||
- External tag editing tools do not disrupt Rosé. If an external tool modifies | ||
the audio tags, Rosé's cache can always update to match the newly modified | ||
source files. | ||
- Rosé is easily synchronized across machines, for example with a tool like | ||
Syncthing. As long as the source files are in-sync, Rosé's read cache will | ||
match. | ||
- An inconsistent state between source files and Rosé is trivially resolved. | ||
This is different from music managers that retain a separate database, | ||
because conflict resolution is then ambiguous. Whereas in Rosé, there are no | ||
conflicts. | ||
|
||
## Stable Release & Track Identifiers | ||
|
||
Rosé assigns UUIDs to each release and track in order to identify them across | ||
arbitrarily large metadata changes. These UUIDs are persisted to the source | ||
files. | ||
|
||
- Each release has a `.rose.{uuid}.toml` file, which preserves release-level | ||
state, such as `New`. The UUID is in the filename instead of the file | ||
contents for improved performance: we can collect the UUID via a `readdir` | ||
call instead of an expensive file read. | ||
- Each track has a custom `roseid` tag. This tag is written to the source audio | ||
file. Read the `tagger.py` file for the exact field name used. | ||
|
||
## Logging | ||
|
||
Logs are written to stderr and to `${XDG_STATE_HOME:-$HOME/.local/state}/rose/rose.log`. | ||
Debug logging can be turned on with the `--verbose/-v` option. Rosé is heavily | ||
instrumented with debug logging. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Maintaining the Cache | ||
|
||
For performance, Rosé stores a copy of every source file's metadata in a SQLite | ||
read cache. The read cache does not accept writes; thus it can always be fully | ||
recreated from the source files. It can be freely deleted and recreated without | ||
consequence. | ||
|
||
The cache can be updated with the command `rose cache update`. By default, the | ||
cache updater will only recheck files that have changed since the last run. To | ||
override this behavior and always re-read file tags, run `rose cache update | ||
--force`. | ||
|
||
By default, the cache is updated on `rose fs mount` and when files are changed | ||
through the virtual filesystem. However, if the `music_source_dir` is changed | ||
directly, Rosé does not automatically update the cache, which can lead to cache | ||
drifts. | ||
|
||
You can solve this problem by running `rose cache watch`. This starts a watcher | ||
that triggers a cache update whenever a source file changes. This can be useful | ||
if you synchronize your music library between two computers, or use another | ||
tool to directly modify the `music_source_dir`. |
Oops, something went wrong.