codetta 0.8.3__tar.gz → 0.8.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. {codetta-0.8.3/src/codetta.egg-info → codetta-0.8.4}/PKG-INFO +17 -17
  2. {codetta-0.8.3 → codetta-0.8.4}/README.md +15 -15
  3. {codetta-0.8.3 → codetta-0.8.4}/pyproject.toml +2 -2
  4. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/CHANGELOG.md +17 -0
  5. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/engine.py +16 -0
  6. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/index.py +18 -1
  7. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/organize.py +27 -2
  8. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/presets.py +1 -1
  9. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/app.py +60 -4
  10. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/app.css +77 -0
  11. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/app.js +75 -21
  12. {codetta-0.8.3 → codetta-0.8.4/src/codetta.egg-info}/PKG-INFO +17 -17
  13. {codetta-0.8.3 → codetta-0.8.4}/tests/test_inbox.py +22 -2
  14. {codetta-0.8.3 → codetta-0.8.4}/tests/test_index.py +25 -0
  15. {codetta-0.8.3 → codetta-0.8.4}/tests/test_safety.py +76 -0
  16. {codetta-0.8.3 → codetta-0.8.4}/LICENSE +0 -0
  17. {codetta-0.8.3 → codetta-0.8.4}/setup.cfg +0 -0
  18. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/__init__.py +0 -0
  19. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/__main__.py +0 -0
  20. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/cli/__init__.py +0 -0
  21. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/cli/__main__.py +0 -0
  22. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/cli/run.py +0 -0
  23. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/__init__.py +0 -0
  24. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/acoustid.py +0 -0
  25. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/activity.py +0 -0
  26. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/artwork.py +0 -0
  27. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/auth.py +0 -0
  28. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/avatar.py +0 -0
  29. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/changelog.py +0 -0
  30. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/connections.py +0 -0
  31. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/describe.py +0 -0
  32. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/health.py +0 -0
  33. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/inbox.py +0 -0
  34. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/library.py +0 -0
  35. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/musicbrainz.py +0 -0
  36. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/notifications.py +0 -0
  37. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/onboarding.py +0 -0
  38. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/plugins.py +0 -0
  39. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/providers.py +0 -0
  40. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/rawtags.py +0 -0
  41. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/slskd.py +0 -0
  42. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/tagmap.py +0 -0
  43. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/undo.py +0 -0
  44. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/core/updates.py +0 -0
  45. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/plugins/__init__.py +0 -0
  46. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/plugins/builtin/__init__.py +0 -0
  47. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/plugins/builtin/tidy.py +0 -0
  48. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/__init__.py +0 -0
  49. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/security.py +0 -0
  50. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/apple-touch-icon.png +0 -0
  51. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/fonts/LICENSE-Inter.txt +0 -0
  52. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/fonts/LICENSE-SchibstedGrotesk.txt +0 -0
  53. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/fonts/inter-cyrillic.woff2 +0 -0
  54. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/fonts/schibsted-grotesk.woff2 +0 -0
  55. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icon.svg +0 -0
  56. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta-dark.png +0 -0
  57. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta-dark.svg +0 -0
  58. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta-dark.webp +0 -0
  59. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta-light.png +0 -0
  60. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta-light.svg +0 -0
  61. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta-light.webp +0 -0
  62. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta.png +0 -0
  63. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta.svg +0 -0
  64. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/icons/codetta.webp +0 -0
  65. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/index.html +0 -0
  66. {codetta-0.8.3 → codetta-0.8.4}/src/codetta/web/static/theme.js +0 -0
  67. {codetta-0.8.3 → codetta-0.8.4}/src/codetta.egg-info/SOURCES.txt +0 -0
  68. {codetta-0.8.3 → codetta-0.8.4}/src/codetta.egg-info/dependency_links.txt +0 -0
  69. {codetta-0.8.3 → codetta-0.8.4}/src/codetta.egg-info/entry_points.txt +0 -0
  70. {codetta-0.8.3 → codetta-0.8.4}/src/codetta.egg-info/requires.txt +0 -0
  71. {codetta-0.8.3 → codetta-0.8.4}/src/codetta.egg-info/top_level.txt +0 -0
  72. {codetta-0.8.3 → codetta-0.8.4}/tests/test_acoustid.py +0 -0
  73. {codetta-0.8.3 → codetta-0.8.4}/tests/test_api.py +0 -0
  74. {codetta-0.8.3 → codetta-0.8.4}/tests/test_artwork.py +0 -0
  75. {codetta-0.8.3 → codetta-0.8.4}/tests/test_attacks.py +0 -0
  76. {codetta-0.8.3 → codetta-0.8.4}/tests/test_auth.py +0 -0
  77. {codetta-0.8.3 → codetta-0.8.4}/tests/test_avatar.py +0 -0
  78. {codetta-0.8.3 → codetta-0.8.4}/tests/test_cli_run.py +0 -0
  79. {codetta-0.8.3 → codetta-0.8.4}/tests/test_connections.py +0 -0
  80. {codetta-0.8.3 → codetta-0.8.4}/tests/test_efficiency.py +0 -0
  81. {codetta-0.8.3 → codetta-0.8.4}/tests/test_engine.py +0 -0
  82. {codetta-0.8.3 → codetta-0.8.4}/tests/test_explore.py +0 -0
  83. {codetta-0.8.3 → codetta-0.8.4}/tests/test_health.py +0 -0
  84. {codetta-0.8.3 → codetta-0.8.4}/tests/test_musicbrainz.py +0 -0
  85. {codetta-0.8.3 → codetta-0.8.4}/tests/test_organize.py +0 -0
  86. {codetta-0.8.3 → codetta-0.8.4}/tests/test_plugins.py +0 -0
  87. {codetta-0.8.3 → codetta-0.8.4}/tests/test_presets.py +0 -0
  88. {codetta-0.8.3 → codetta-0.8.4}/tests/test_privacy.py +0 -0
  89. {codetta-0.8.3 → codetta-0.8.4}/tests/test_providers.py +0 -0
  90. {codetta-0.8.3 → codetta-0.8.4}/tests/test_rawtags.py +0 -0
  91. {codetta-0.8.3 → codetta-0.8.4}/tests/test_security.py +0 -0
  92. {codetta-0.8.3 → codetta-0.8.4}/tests/test_slskd.py +0 -0
  93. {codetta-0.8.3 → codetta-0.8.4}/tests/test_soulseek_api.py +0 -0
  94. {codetta-0.8.3 → codetta-0.8.4}/tests/test_undo.py +0 -0
  95. {codetta-0.8.3 → codetta-0.8.4}/tests/test_updates.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codetta
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: A private, self-hosted music library manager: tags, MusicBrainz matching, batch editing and organizing, in your browser
5
- Author: Gavin Griggs
5
+ Author: gavndev
6
6
  License-Expression: AGPL-3.0-or-later
7
7
  Project-URL: Homepage, https://github.com/gavndev/codetta
8
8
  Project-URL: Documentation, https://github.com/gavndev/codetta/tree/main/docs
@@ -31,8 +31,8 @@ Dynamic: license-file
31
31
 
32
32
  <p align="center">
33
33
  <picture>
34
- <source media="(prefers-color-scheme: dark)" srcset="docs/media/hero-dark.gif">
35
- <img src="docs/media/hero-light.gif" alt="Codetta: your music library, looked after. Fix tags, match albums on MusicBrainz and organize your files, from any browser." width="900">
34
+ <source media="(prefers-color-scheme: dark)" srcset="docs/brand/logo-dark.svg">
35
+ <img src="docs/brand/logo-light.svg" alt="Codetta" height="64">
36
36
  </picture>
37
37
  </p>
38
38
 
@@ -44,7 +44,7 @@ Dynamic: license-file
44
44
 
45
45
  <p align="center">
46
46
  <img alt="Status: alpha" src="https://img.shields.io/badge/status-alpha-f59e0b">
47
- <img alt="Version 0.8.3" src="https://img.shields.io/badge/version-0.8.3-0e7c74">
47
+ <img alt="Version 0.8.4" src="https://img.shields.io/badge/version-0.8.4-0e7c74">
48
48
  <a href="LICENSE"><img alt="License: AGPL-3.0" src="https://img.shields.io/badge/license-AGPL--3.0-555"></a>
49
49
  <img alt="Python 3.14" src="https://img.shields.io/badge/python-3.14-3776ab">
50
50
  <a href="https://github.com/gavndev/codetta/actions/workflows/ci.yml"><img alt="Tests" src="https://github.com/gavndev/codetta/actions/workflows/ci.yml/badge.svg"></a>
@@ -53,7 +53,10 @@ Dynamic: license-file
53
53
  </p>
54
54
 
55
55
  <p align="center">
56
- <img src="docs/media/overview.gif" alt="A tour of Codetta: editing an album's tags, searching the library by tag, looking up an artist on MusicBrainz, a one-tap Library health fix, the player with synced lyrics, and the account panel" width="900">
56
+ <picture>
57
+ <source media="(prefers-color-scheme: dark)" srcset="docs/media/hero-dark.gif">
58
+ <img src="docs/media/hero-light.gif" alt="Codetta: your music library, looked after. Fix tags, match albums on MusicBrainz and organize your files, from any browser." width="900">
59
+ </picture>
57
60
  </p>
58
61
 
59
62
  <p align="center">
@@ -112,8 +115,8 @@ Runs on Intel/AMD and ARM, from a Raspberry Pi 4 up: about a 100 MB download
112
115
  and 70 MB of memory (about 130 MB at 100,000 tracks), and no disk activity when idle. The
113
116
  [install guide](docs/install.md) walks through every step, including updates.
114
117
 
115
- No server? Run it on your own computer instead:
116
- `pipx install codetta`, then `codetta`
118
+ No server? Run it on your own computer instead: `pipx install codetta`
119
+ (or `sudo snap install codetta` on Ubuntu), then `codetta`
117
120
  ([details](docs/install.md#on-your-own-computer)).
118
121
 
119
122
  ## What Codetta does
@@ -259,14 +262,10 @@ light and dark themes. [See every feature →](docs/features.md)
259
262
 
260
263
  ## What's new
261
264
 
262
- **0.6.x:** a security sweep and a faster app (compressed pages, quicker
263
- folders), download progress in the inbox, a roomier top bar on phones, and an
264
- optional slskd integration.
265
- **0.5.0:** the import inbox, Organize (rename and move from a pattern), quick
266
- listen with a now-playing pill, multi-disc albums, setup steps, What's new and
267
- notifications.
268
- **0.4.0:** offline unless you opt in; Match on MusicBrainz and identify by
269
- sound with AcoustID. All changes are in the [changelog](CHANGELOG.md).
265
+ Every change is in the [changelog](CHANGELOG.md); each version's notes are also on
266
+ [GitHub Releases](https://github.com/gavndev/codetta/releases). Inside Codetta,
267
+ **What's new** (in the account menu, or the link in the footer) shows the same notes for the
268
+ version you're running.
270
269
 
271
270
  ## License
272
271
 
@@ -279,4 +278,5 @@ Built with [mutagen](https://github.com/quodlibet/mutagen),
279
278
  [Schibsted Grotesk](https://github.com/schibsted/schibsted-grotesk) typeface.
280
279
  Tag mappings follow [MusicBrainz Picard](https://picard.musicbrainz.org/docs/mappings/).
281
280
  The optional Soulseek integration talks to [slskd](https://github.com/slskd/slskd) over its API.
282
- The artists and albums in the screenshots are made up.
281
+ The header and screenshots show real releases for illustration (the covers belong to their
282
+ artists and labels; the audio files are silent stand-ins); the feature GIFs use made-up music.
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="docs/media/hero-dark.gif">
4
- <img src="docs/media/hero-light.gif" alt="Codetta: your music library, looked after. Fix tags, match albums on MusicBrainz and organize your files, from any browser." width="900">
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/brand/logo-dark.svg">
4
+ <img src="docs/brand/logo-light.svg" alt="Codetta" height="64">
5
5
  </picture>
6
6
  </p>
7
7
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  <p align="center">
15
15
  <img alt="Status: alpha" src="https://img.shields.io/badge/status-alpha-f59e0b">
16
- <img alt="Version 0.8.3" src="https://img.shields.io/badge/version-0.8.3-0e7c74">
16
+ <img alt="Version 0.8.4" src="https://img.shields.io/badge/version-0.8.4-0e7c74">
17
17
  <a href="LICENSE"><img alt="License: AGPL-3.0" src="https://img.shields.io/badge/license-AGPL--3.0-555"></a>
18
18
  <img alt="Python 3.14" src="https://img.shields.io/badge/python-3.14-3776ab">
19
19
  <a href="https://github.com/gavndev/codetta/actions/workflows/ci.yml"><img alt="Tests" src="https://github.com/gavndev/codetta/actions/workflows/ci.yml/badge.svg"></a>
@@ -22,7 +22,10 @@
22
22
  </p>
23
23
 
24
24
  <p align="center">
25
- <img src="docs/media/overview.gif" alt="A tour of Codetta: editing an album's tags, searching the library by tag, looking up an artist on MusicBrainz, a one-tap Library health fix, the player with synced lyrics, and the account panel" width="900">
25
+ <picture>
26
+ <source media="(prefers-color-scheme: dark)" srcset="docs/media/hero-dark.gif">
27
+ <img src="docs/media/hero-light.gif" alt="Codetta: your music library, looked after. Fix tags, match albums on MusicBrainz and organize your files, from any browser." width="900">
28
+ </picture>
26
29
  </p>
27
30
 
28
31
  <p align="center">
@@ -81,8 +84,8 @@ Runs on Intel/AMD and ARM, from a Raspberry Pi 4 up: about a 100 MB download
81
84
  and 70 MB of memory (about 130 MB at 100,000 tracks), and no disk activity when idle. The
82
85
  [install guide](docs/install.md) walks through every step, including updates.
83
86
 
84
- No server? Run it on your own computer instead:
85
- `pipx install codetta`, then `codetta`
87
+ No server? Run it on your own computer instead: `pipx install codetta`
88
+ (or `sudo snap install codetta` on Ubuntu), then `codetta`
86
89
  ([details](docs/install.md#on-your-own-computer)).
87
90
 
88
91
  ## What Codetta does
@@ -228,14 +231,10 @@ light and dark themes. [See every feature →](docs/features.md)
228
231
 
229
232
  ## What's new
230
233
 
231
- **0.6.x:** a security sweep and a faster app (compressed pages, quicker
232
- folders), download progress in the inbox, a roomier top bar on phones, and an
233
- optional slskd integration.
234
- **0.5.0:** the import inbox, Organize (rename and move from a pattern), quick
235
- listen with a now-playing pill, multi-disc albums, setup steps, What's new and
236
- notifications.
237
- **0.4.0:** offline unless you opt in; Match on MusicBrainz and identify by
238
- sound with AcoustID. All changes are in the [changelog](CHANGELOG.md).
234
+ Every change is in the [changelog](CHANGELOG.md); each version's notes are also on
235
+ [GitHub Releases](https://github.com/gavndev/codetta/releases). Inside Codetta,
236
+ **What's new** (in the account menu, or the link in the footer) shows the same notes for the
237
+ version you're running.
239
238
 
240
239
  ## License
241
240
 
@@ -248,4 +247,5 @@ Built with [mutagen](https://github.com/quodlibet/mutagen),
248
247
  [Schibsted Grotesk](https://github.com/schibsted/schibsted-grotesk) typeface.
249
248
  Tag mappings follow [MusicBrainz Picard](https://picard.musicbrainz.org/docs/mappings/).
250
249
  The optional Soulseek integration talks to [slskd](https://github.com/slskd/slskd) over its API.
251
- The artists and albums in the screenshots are made up.
250
+ The header and screenshots show real releases for illustration (the covers belong to their
251
+ artists and labels; the audio files are silent stand-ins); the feature GIFs use made-up music.
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codetta"
7
- version = "0.8.3"
7
+ version = "0.8.4"
8
8
  description = "A private, self-hosted music library manager: tags, MusicBrainz matching, batch editing and organizing, in your browser"
9
9
  readme = "README.md"
10
- authors = [{ name = "Gavin Griggs" }]
10
+ authors = [{ name = "gavndev" }]
11
11
  keywords = ["music", "tags", "tagger", "metadata", "musicbrainz", "flac", "id3", "self-hosted", "library", "organizer"]
12
12
  classifiers = [
13
13
  "Development Status :: 4 - Beta",
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to Codetta. Versions follow [Semantic Versioning](https://semver.org/).
4
4
 
5
+ ## 0.8.4 (2026-11-19)
6
+
7
+ - **Covers in the grid view:** switch the Library to the grid and every folder shows the cover of an album inside it, artists included. Nothing extra is read from your disk: the covers come from the search index.
8
+ - **Easier to tap on phones:** every button, field and toggle is now at least 44 points tall, as Apple recommends. The search bar responds anywhere you tap it, not just on a thin strip in the middle.
9
+ - **Selecting tracks on a phone:** the bar at the bottom no longer runs off the screen. Preset, Replace and Actions now share a "…" menu next to Edit.
10
+ - **Safer moves:** Organize, Rename folder and the inbox now move a file in a way that can never replace another file that appears at the same name at the last moment (say, a download finishing). Very long file names also move between disks correctly now.
11
+ - **Saves survive power cuts better:** after a file is safely swapped in, its folder is flushed to disk too.
12
+ - **Fixed:** filing the same inbox album twice at once (a double tap, or "File all" while it was filing itself) could mark a successfully filed album as failed. A second request is now turned away.
13
+ - **Fixed:** a double tap on Undo could run the same undo twice, and undoing a move whose folder no longer exists showed a server error instead of saying why.
14
+ - **Fixed:** after saving, going back to a search or a grid could still show the old tags or cover until you reloaded.
15
+ - **Fixed:** a MusicBrainz match that saved the tags but not the cover left search and Library health showing the old tags.
16
+ - **Fixed:** pressing Ctrl/Cmd+S twice quickly saved everything twice (and logged it twice). A save already under way now just carries on.
17
+ - The "/" shortcut for search no longer jumps behind an open dialog.
18
+ - **Fixed:** applying a Tag Preset to a folder stopped part-way if one file couldn't be opened (say, a permissions problem), and the files it had already changed weren't in Activity, so they couldn't be undone. Now that one file is reported and the rest carry on, all undoable.
19
+ - **Library health's one-tap fixes** check the album again first if anything changed since the list was made.
20
+ - **What's new** shows its links properly (they opened as plain text before) and they now open on GitHub.
21
+
5
22
  ## 0.8.3 (2026-11-19)
6
23
 
7
24
  (0.8.2 was tagged but never released: our tests caught the Library health bug below just in time.)
@@ -306,6 +306,7 @@ class MetadataEngine:
306
306
  # client still seeding it) keeps the original bytes.
307
307
  os.replace(temp_path, target)
308
308
  temp_path = None
309
+ _fsync_dir(target.parent) # and the new name too, so a power cut can't undo the swap
309
310
  except OSError as exc:
310
311
  raise MetadataError(f"Could not write to {path}: {exc}") from exc
311
312
  finally:
@@ -459,6 +460,21 @@ def _normalize_value(value: TagValue) -> list[str]:
459
460
  return [] if all(v == "" for v in values) else values
460
461
 
461
462
 
463
+ def _fsync_dir(folder: Path) -> None:
464
+ """Flush a folder's entries (a rename) to disk. Best effort: not every system or
465
+ filesystem supports it (Windows, some network shares), and the data is already safe."""
466
+ try:
467
+ fd = os.open(folder, os.O_RDONLY | getattr(os, "O_DIRECTORY", 0))
468
+ except OSError:
469
+ return
470
+ try:
471
+ os.fsync(fd)
472
+ except OSError:
473
+ pass
474
+ finally:
475
+ os.close(fd)
476
+
477
+
462
478
  def _copy_ownership(source: Path, dest: Path) -> None:
463
479
  """Give ``dest`` the same owner/group as ``source`` where permitted.
464
480
 
@@ -43,7 +43,7 @@ from dataclasses import dataclass, field
43
43
  from pathlib import Path
44
44
 
45
45
  from codetta.core.engine import SUPPORTED_EXTENSIONS
46
- from codetta.core.library import _is_valid_text, _sort_text, natural_key
46
+ from codetta.core.library import _is_valid_text, _sort_text
47
47
  from codetta.core.tagmap import FIELDS
48
48
 
49
49
  log = logging.getLogger("codetta.index")
@@ -628,6 +628,23 @@ class LibraryIndex:
628
628
  yield path, _unpack(blob)
629
629
  last = rows[-1][0]
630
630
 
631
+ def cover_tracks(self, folders: Iterable[str], look: int = 30) -> dict[str, tuple[str, str]]:
632
+ """For each folder, a track inside it (at any depth) that has embedded art:
633
+ folder -> (track path, art hash). Reads the index only (no file is opened); looks at the
634
+ first ``look`` tracks of each folder, so a huge folder never makes this slow."""
635
+ out: dict[str, tuple[str, str]] = {}
636
+ with self._lock:
637
+ for folder in folders:
638
+ lo, hi = (folder + "/", folder + "0") if folder else ("", "\U0010ffff") # "0" sorts right after "/"
639
+ rows = self.db.execute("SELECT path, track FROM files WHERE path >= ? AND path < ? ORDER BY path LIMIT ?",
640
+ (lo, hi, look)).fetchall()
641
+ for path, blob in rows:
642
+ art = _unpack(blob).get("art") or {}
643
+ if art.get("hash"):
644
+ out[folder] = (path, art["hash"])
645
+ break
646
+ return out
647
+
631
648
  def paths_with_any(self, keys: Iterable[str]) -> set[str]:
632
649
  """Files that have at least one of these tags (by name, any case)."""
633
650
  with self._lock:
@@ -22,8 +22,11 @@ every move (see ``undo_moves``).
22
22
 
23
23
  from __future__ import annotations
24
24
 
25
+ import contextlib
26
+ import errno
25
27
  import os
26
28
  import re
29
+ import secrets
27
30
  import shutil
28
31
  import threading
29
32
  import unicodedata
@@ -361,18 +364,40 @@ def _move_one(root: Root, src: str, dst: str) -> None:
361
364
  if os.path.lexists(b) and not _same_file(a, b):
362
365
  raise FileExistsError("A different file already has that name")
363
366
  b.parent.mkdir(parents=True, exist_ok=True)
367
+ if not a.is_dir() and not _same_file(a, b) and _link_then_unlink(a, b):
368
+ return
364
369
  try:
365
370
  os.rename(a, b) # same filesystem: instant, and the file itself is never rewritten
366
371
  except OSError as exc:
367
- if exc.errno != 18: # EXDEV: another disk or mount (e.g. the inbox folder)
372
+ if exc.errno != errno.EXDEV: # another disk or mount (e.g. the inbox folder)
368
373
  raise
369
374
  _copy_then_remove(a, b)
370
375
 
371
376
 
377
+ def _link_then_unlink(a: Path, b: Path) -> bool:
378
+ """Move a file without any chance of replacing one that appeared at ``b`` a moment ago
379
+ (a plain rename would silently overwrite it). True when done; False when hard links
380
+ aren't possible here (another disk, exFAT, some network shares), so the caller renames."""
381
+ try:
382
+ os.link(a, b, follow_symlinks=False)
383
+ except FileExistsError:
384
+ raise FileExistsError("A different file already has that name") from None
385
+ except OSError:
386
+ return False
387
+ try:
388
+ os.unlink(a)
389
+ except OSError:
390
+ with contextlib.suppress(OSError):
391
+ os.unlink(b) # couldn't let go of the old name: put things back as they were
392
+ raise
393
+ return True
394
+
395
+
372
396
  def _copy_then_remove(a: Path, b: Path) -> None:
373
397
  """Move across disks: copy to a temporary name next to the target, check
374
398
  it, give it its real name, and only then delete the original."""
375
- tmp = b.with_name(f".codetta-move-{os.getpid()}-{b.name}")
399
+ # A short temporary name: the real one may already be at the 255-byte limit.
400
+ tmp = b.with_name(f".codetta-move-{os.getpid()}-{secrets.token_hex(4)}{b.suffix[:16]}")
376
401
  try:
377
402
  if a.is_dir() and not a.is_symlink():
378
403
  shutil.copytree(a, tmp, symlinks=True)
@@ -299,7 +299,7 @@ def _apply_one(
299
299
  result.previous = {k: list(current.tags.get(k, [])) for k in changes}
300
300
  if changes and not dry_run:
301
301
  engine.update_tags(path, changes)
302
- except (MetadataError, FileNotFoundError) as exc:
302
+ except (MetadataError, OSError) as exc: # any one file failing (unreadable, no permission) never stops the rest
303
303
  result.applied = {}
304
304
  result.error = str(exc)
305
305
  return result
@@ -48,7 +48,7 @@ from contextlib import asynccontextmanager
48
48
  from dataclasses import dataclass
49
49
  from importlib.metadata import PackageNotFoundError, version
50
50
  from pathlib import Path
51
- from typing import Literal
51
+ from typing import Annotated, Literal
52
52
  from urllib.parse import urlsplit
53
53
 
54
54
  from fastapi import FastAPI, HTTPException, Query, Request
@@ -351,6 +351,10 @@ def _unique(paths: list[str]) -> list[str]:
351
351
  return list(dict.fromkeys(paths))
352
352
 
353
353
 
354
+ class FolderCoversIn(BaseModel):
355
+ paths: list[Annotated[str, Field(max_length=MAX_PATH_CHARS)]] = Field(max_length=200)
356
+
357
+
354
358
  class UpdateIn(BaseModel):
355
359
  paths: list[str] = Field(min_length=1, max_length=MAX_PATHS_PER_REQUEST)
356
360
  # Tag name -> new value(s). null, "" or [] removes the tag.
@@ -1013,6 +1017,20 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
1013
1017
  tracks=tracks_out(listing.files),
1014
1018
  )
1015
1019
 
1020
+ @app.post("/api/folder-covers")
1021
+ def folder_covers(body: FolderCoversIn) -> dict:
1022
+ """A cover for each folder in the grid: a track inside it with embedded art (from the
1023
+ search index, so nothing is read from disk). The page shows it with /api/art."""
1024
+ require_library()
1025
+ folders = []
1026
+ for rel in body.paths:
1027
+ try:
1028
+ folders.append(library.relative(library.resolve(rel))) # rejects anything outside the library
1029
+ except (LibraryPathError, ValueError):
1030
+ continue
1031
+ found = lib_index.cover_tracks(f for f in folders if not f.startswith("@"))
1032
+ return {"covers": {f: {"path": p, "hash": h} for f, (p, h) in found.items()}}
1033
+
1016
1034
  @app.get("/api/track", response_model=TrackOut)
1017
1035
  def get_track(path: str = Query(..., max_length=MAX_PATH_CHARS, description="File, relative to the music folder")):
1018
1036
  require_library()
@@ -1374,7 +1392,8 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
1374
1392
  undo = parts[0] if len(parts) == 1 else {"type": "multi", "parts": parts} if parts else None
1375
1393
  if results:
1376
1394
  _log_musicbrainz(activity, summary, proposal["files"], results, bool(art_undo), undo)
1377
- lib_index.mark_dirty(r["path"] for r in results if r["ok"])
1395
+ # Every file that changed, including one whose tags saved but cover didn't.
1396
+ lib_index.mark_dirty({r["path"] for r in results if r["ok"]} | set(tag_undo) | set(art_undo))
1378
1397
  return {
1379
1398
  "release": summary,
1380
1399
  "results": results,
@@ -1684,6 +1703,8 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
1684
1703
  if exact and inbox_auto(key):
1685
1704
  inbox_file(key, automatic=True)
1686
1705
  except HTTPException as exc:
1706
+ if exc.status_code == 409 and key in inbox_filing:
1707
+ return # someone tapped "File" a moment earlier: that filing carries on
1687
1708
  inbox.update(key, status=INBOX_ERROR, title=title, artist=artist, note=str(exc.detail))
1688
1709
 
1689
1710
  def inbox_auto(key: str) -> bool:
@@ -1694,7 +1715,23 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
1694
1715
  return not soulseek_store.settings.review
1695
1716
  return inbox.settings.auto
1696
1717
 
1718
+ inbox_filing: set[str] = set()
1719
+ inbox_filing_lock = threading.Lock()
1720
+
1697
1721
  def inbox_file(key: str, release: str | None = None, recordings: dict | None = None, automatic: bool = False) -> dict:
1722
+ """File one album. A second request for the same album while it's being filed (a double
1723
+ tap, or "File all" while it's filing itself) is turned away instead of running twice."""
1724
+ with inbox_filing_lock:
1725
+ if key in inbox_filing:
1726
+ raise HTTPException(409, "This album is already being filed.")
1727
+ inbox_filing.add(key)
1728
+ try:
1729
+ return inbox_file_locked(key, release, recordings, automatic)
1730
+ finally:
1731
+ with inbox_filing_lock:
1732
+ inbox_filing.discard(key)
1733
+
1734
+ def inbox_file_locked(key: str, release: str | None, recordings: dict | None, automatic: bool) -> dict:
1698
1735
  g = inbox.groups.get(key)
1699
1736
  if g is None:
1700
1737
  raise HTTPException(404, "That album is no longer in the inbox")
@@ -1908,7 +1945,13 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
1908
1945
  """File every confident match in one go."""
1909
1946
  require_library()
1910
1947
  keys = [g.key for g in list(inbox.groups.values()) if g.status == READY]
1911
- filed = sum(inbox_file(k)["status"] == FILED for k in keys)
1948
+ filed = 0
1949
+ for k in keys:
1950
+ try:
1951
+ filed += inbox_file(k)["status"] == FILED
1952
+ except HTTPException as exc:
1953
+ if exc.status_code != 409: # 409: already being filed, by itself or another tap
1954
+ raise
1912
1955
  return {"filed": filed, "total": len(keys), "inbox": inbox_out()}
1913
1956
 
1914
1957
  @app.post("/api/inbox/skip")
@@ -2434,6 +2477,10 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
2434
2477
  require_library()
2435
2478
  if not health_store.enabled:
2436
2479
  raise HTTPException(409, "Library health is switched off.")
2480
+ with health_lock:
2481
+ stale = health_cache["key"] != lib_index.version
2482
+ if stale: # the library changed since this list was made: check again before writing anything
2483
+ health_compute()
2437
2484
  issue = next((i for i in health_data()["issues"] if i["id"] == body.id), None)
2438
2485
  if issue is None:
2439
2486
  raise HTTPException(404, "That issue is gone (fixed already?)")
@@ -2636,10 +2683,16 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
2636
2683
  lib_index.mark_dirty(done)
2637
2684
  return done, failed
2638
2685
 
2686
+ undo_lock = threading.Lock() # one undo at a time: a double tap can't run the same undo twice
2687
+
2639
2688
  @app.post("/api/activity/{entry_id}/undo")
2640
2689
  def undo(entry_id: int) -> dict:
2641
2690
  """Reverse a logged change. Files edited again since are left alone."""
2642
2691
  require_library()
2692
+ with undo_lock:
2693
+ return undo_locked(entry_id)
2694
+
2695
+ def undo_locked(entry_id: int) -> dict:
2643
2696
  entry = activity.get(entry_id)
2644
2697
  if entry is None:
2645
2698
  raise HTTPException(404, "That change is no longer in the activity log")
@@ -2647,7 +2700,10 @@ def create_app(settings: Settings | None = None, fetch_release: Fetcher = fetch_
2647
2700
  raise HTTPException(422, "This change can't be undone")
2648
2701
  if activity.is_undone(entry_id):
2649
2702
  raise HTTPException(409, "This change has already been undone")
2650
- outcome = undo_change(engine, library.resolve, art_store, entry["undo"])
2703
+ try:
2704
+ outcome = undo_change(engine, library.resolve, art_store, entry["undo"])
2705
+ except LibraryPathError as exc: # e.g. it moved files in the inbox, and there's no inbox folder now
2706
+ raise HTTPException(409, f"This change can't be undone any more: {exc}") from exc
2651
2707
  lib_index.mark_dirty(r.path for r in outcome.results if r.ok)
2652
2708
  if entry["undo"].get("type") == "moves" and outcome.reverse:
2653
2709
  lib_index.mark_dirty(p for pair in outcome.reverse["moves"] for p in pair if not p.startswith("@"))
@@ -1971,6 +1971,7 @@ body:has(.now-playing:not([hidden])) .browser { padding-bottom: 120px; }
1971
1971
  .news-version h3 { font-size: 15px; font-weight: 800; display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
1972
1972
  .news-date { font-size: 12px; font-weight: 500; color: var(--muted); }
1973
1973
  .news-version ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
1974
+ .news-version a { color: var(--accent); text-underline-offset: 2px; }
1974
1975
  .news-version li { line-height: 1.45; }
1975
1976
  .news-version code { font-family: var(--mono); font-size: 12px; background: var(--hover); padding: 0 4px; border-radius: 3px; overflow-wrap: anywhere; }
1976
1977
  .news-more { min-height: 36px; }
@@ -2682,3 +2683,79 @@ dialog.player-sheet { width: min(480px, calc(100vw - 32px)); }
2682
2683
  .btn.icon-expand.tool-more { display: inline-flex; }
2683
2684
  }
2684
2685
  .btn.icon-expand.tool-more .icon-expand-label { display: none; }
2686
+
2687
+ /* ---- Phones: 44px touch targets everywhere (Apple's minimum) ------------------------ */
2688
+ @media (max-width: 760px) {
2689
+ .icon-btn { width: 44px; height: 44px; }
2690
+ .topbar-actions > .icon-btn { margin-left: -8px; } /* same visual spacing as before */
2691
+ .brand { min-width: 44px; min-height: 44px; justify-content: center; padding: 0; }
2692
+ input[type="text"], input:not([type]), input[type="password"], input[type="search"], select { height: 44px; }
2693
+ .search { height: 44px; }
2694
+ .search input { height: 100%; } /* the whole bar takes the tap, not a 25px strip */
2695
+ .auth-card input, .auth-submit { height: 44px; }
2696
+ .credit-news { padding: 13px 6px; margin: -13px -6px; } /* a small link with a full-size touch area */
2697
+ .crumbs a:nth-last-of-type(2) { min-height: 44px; }
2698
+ .view-toggle .icon-btn { width: 44px; height: 40px; }
2699
+ .btn.icon-expand { width: 44px; height: 44px; min-width: 44px; }
2700
+ .folder-actions .mb-find-inner { height: 41px; }
2701
+ .play-btn { height: 44px; min-width: 44px; border-radius: 22px; }
2702
+ .btn { min-height: 44px; }
2703
+ /* The selection bar: count, Clear, "…" (Preset, Replace, Actions) and Edit fit on one row. */
2704
+ #sel-preset, #sel-replace, #sel-actions { display: none; }
2705
+ .selection-bar { gap: 10px; padding-left: 14px; }
2706
+ #selection-count { white-space: nowrap; }
2707
+ }
2708
+
2709
+ /* Selection bar and playing bar both showing: keep the last rows clear of them. */
2710
+ body:has(.selection-bar:not([hidden])):has(.now-playing:not([hidden])) .browser { padding-bottom: 190px; }
2711
+
2712
+ /* ---- Grid view: covers ---------------------------------------------------------------- */
2713
+ .folders:not(.as-list) { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 24px 22px; }
2714
+ .folders:not(.as-list) .folder {
2715
+ flex-direction: column; align-items: stretch; gap: 10px; min-height: 0; padding: 0;
2716
+ border: 0; background: transparent; font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
2717
+ }
2718
+ @media (hover: hover) { .folders:not(.as-list) .folder:hover { background: transparent; } }
2719
+ .folder-cover {
2720
+ aspect-ratio: 1; border-radius: 4px; overflow: hidden; display: grid; place-items: center;
2721
+ background: var(--hover); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 20px -10px rgba(0, 0, 0, 0.35);
2722
+ transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
2723
+ }
2724
+ .folder-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
2725
+ .folders:not(.as-list) .folder-cover svg { width: 30%; height: 30%; color: var(--faint); }
2726
+ @media (hover: hover) {
2727
+ .folders:not(.as-list) .folder:hover .folder-cover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 16px 30px -12px rgba(0, 0, 0, 0.45); }
2728
+ }
2729
+ .folders:not(.as-list) .folder:active .folder-cover { transform: scale(0.98); }
2730
+ .folder-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
2731
+ .folder-text .folder-meta { font-size: 13px; font-weight: 400; letter-spacing: 0; }
2732
+ @media (max-width: 760px) {
2733
+ .folders:not(.as-list) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; border-top: 0; }
2734
+ .folders:not(.as-list) .folder { border: 0; min-height: 0; }
2735
+ }
2736
+
2737
+ /* Phones: the smaller controls get full-size touch areas too (looks stay the same where possible). */
2738
+ @media (max-width: 760px) {
2739
+ .view-toggle { padding: 0; }
2740
+ .view-toggle .icon-btn { width: 44px; height: 44px; }
2741
+ .input-wrap input { padding-right: 46px; }
2742
+ .input-wrap .clear { right: 0; width: 44px; height: 44px; } /* the "clear" cross fills the field's end */
2743
+ .segmented span { height: 40px; } /* + the control's 2px inset = a 44px row */
2744
+ .chip-btn, .health-chip { min-height: 44px; }
2745
+ .link-btn { min-height: 44px; padding: 0 4px; }
2746
+ summary { min-height: 44px; display: flex; align-items: center; }
2747
+ .np-close, .np-next { width: 44px; height: 44px; }
2748
+ .ps-tabs button { min-height: 44px; }
2749
+ #conn-toggle, #plugins-toggle, #pw-toggle { min-height: 52px; }
2750
+ .credit-news { padding: 14px 6px; margin: -14px -6px; }
2751
+ }
2752
+ @media (max-width: 760px) {
2753
+ .activity-head { min-height: 44px; }
2754
+ .sk-files summary { min-height: 44px; }
2755
+ /* Checkbox rows ("Match case", "Remember this pattern"): the whole row is the tap target. */
2756
+ label:has(> input[type="checkbox"]:not([role="switch"])) { min-height: 44px; display: inline-flex; align-items: center; }
2757
+ .ps-seek { height: 44px; } /* the player sheet's slider: easy to grab with a thumb */
2758
+ }
2759
+
2760
+ /* A sheet focused as a whole when it opens (see openDialog): no ring around the whole sheet. */
2761
+ dialog:focus { outline: none; }