audio-transcode-watcher 0.7.0__tar.gz → 0.7.1__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 (63) hide show
  1. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/CHANGELOG.md +8 -0
  2. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/PKG-INFO +2 -2
  3. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/README.md +1 -1
  4. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/config.example.yaml +1 -1
  5. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/ROADMAP.md +1 -1
  6. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/getting-started.md +2 -2
  7. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/pyproject.toml +1 -1
  8. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/__init__.py +1 -1
  9. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/encoder.py +8 -6
  10. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/lyrics.py +1 -1
  11. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/main.py +10 -8
  12. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/sync.py +37 -25
  13. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/utils.py +4 -0
  14. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_replaygain.py +43 -0
  15. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/uv.lock +1 -1
  16. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/.gitignore +0 -0
  17. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/README.md +0 -0
  18. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/config.yaml +0 -0
  19. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/hooks/commit-msg +0 -0
  20. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/hooks/post-checkout +0 -0
  21. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/hooks/post-merge +0 -0
  22. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/hooks/pre-commit +0 -0
  23. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/hooks/pre-push +0 -0
  24. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/hooks/prepare-commit-msg +0 -0
  25. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.beads/metadata.json +0 -0
  26. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.claude/settings.json +0 -0
  27. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.coderabbit.yaml +0 -0
  28. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.github/FUNDING.yml +0 -0
  29. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.github/dependabot.yml +0 -0
  30. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.github/workflows/dockerhub-description.yml +0 -0
  31. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.github/workflows/release.yml +0 -0
  32. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.github/workflows/stale.yml +0 -0
  33. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.github/workflows/tests.yml +0 -0
  34. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/.gitignore +0 -0
  35. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/AGENTS.md +0 -0
  36. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/CLAUDE.md +0 -0
  37. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/Dockerfile +0 -0
  38. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/LICENSE +0 -0
  39. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/SECURITY.md +0 -0
  40. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/codecov.yml +0 -0
  41. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/configuration.md +0 -0
  42. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/development.md +0 -0
  43. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/how-it-works.md +0 -0
  44. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/images/banner.svg +0 -0
  45. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/images/icon.png +0 -0
  46. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/images/icon.svg +0 -0
  47. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/images/social-preview.png +0 -0
  48. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/docs/usage.md +0 -0
  49. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/config.py +0 -0
  50. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/manifest.py +0 -0
  51. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/replaygain.py +0 -0
  52. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/src/audio_transcode_watcher/watcher.py +0 -0
  53. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/__init__.py +0 -0
  54. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/conftest.py +0 -0
  55. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_config.py +0 -0
  56. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_encoder.py +0 -0
  57. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_lyrics.py +0 -0
  58. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_main.py +0 -0
  59. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_manifest.py +0 -0
  60. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_sync.py +0 -0
  61. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_utils.py +0 -0
  62. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tests/test_watcher.py +0 -0
  63. {audio_transcode_watcher-0.7.0 → audio_transcode_watcher-0.7.1}/tools/verify_sync.py +0 -0
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
4
4
 
5
+ ## [0.7.1] - 2026-10-07
6
+
7
+ ### Fixed
8
+
9
+ - An output whose ReplayGain tags could not be written is now tried again on the next periodic sync. Before, one failed write (for example a root-owned ALAC file answering "Permission denied") marked its source as done, so the output stayed untagged until the source changed or the service restarted. Each failed attempt logs the same warning, and the source counts as done only once every output has its tags.
10
+ - Errors are no longer swallowed silently. File operations now catch only filesystem errors and log them as before. The broad catches that stay, such as the one around each file of a sync, log the full traceback, and lyric metadata reads and unreadable folders log at debug level. A failed removal of a leftover temp file is now logged too.
11
+
5
12
  ## [0.7.0] - 2026-10-06
6
13
 
7
14
  ### Added
@@ -65,6 +72,7 @@ All notable changes to this project are documented here. The format follows [Kee
65
72
  - Lossy copies are written through a temp file and renamed, like encodes, so a half-written copy is never visible.
66
73
  - `force_reencode: true` purges the outputs once at startup. It used to purge them again on every periodic sync, which re-encoded the whole library every five minutes.
67
74
 
75
+ [0.7.1]: https://github.com/GeiserX/audio-transcode-watcher/releases/tag/v0.7.1
68
76
  [0.7.0]: https://github.com/GeiserX/audio-transcode-watcher/releases/tag/v0.7.0
69
77
  [0.6.2]: https://github.com/GeiserX/audio-transcode-watcher/releases/tag/v0.6.2
70
78
  [0.6.1]: https://github.com/GeiserX/audio-transcode-watcher/releases/tag/v0.6.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: audio-transcode-watcher
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Watch a source folder and automatically transcode audio files to multiple formats
5
5
  Project-URL: Homepage, https://github.com/GeiserX/audio-transcode-watcher
6
6
  Project-URL: Repository, https://github.com/GeiserX/audio-transcode-watcher
@@ -67,7 +67,7 @@ Keep one library in several formats: lossless for the archive, lossy for phones
67
67
  curl -fsSL -o config.yaml https://raw.githubusercontent.com/GeiserX/audio-transcode-watcher/main/config.example.yaml
68
68
  docker run -d --name audio_transcoder -e CONFIG_FILE=/app/config.yaml \
69
69
  -v ./config.yaml:/app/config.yaml:ro -v /path/to/flac:/music/flac:ro -v /path/to/mp3:/music/mp3 \
70
- drumsergio/audio-transcoder:0.7.0
70
+ drumsergio/audio-transcoder:0.7.1
71
71
  ```
72
72
 
73
73
  Edit `config.yaml` first so its outputs match the folders you mount; the example writes ALAC, MP3 and AAC. [Getting started](https://github.com/GeiserX/audio-transcode-watcher/blob/main/docs/getting-started.md) has Docker Compose and the full `docker run`.
@@ -36,7 +36,7 @@ Keep one library in several formats: lossless for the archive, lossy for phones
36
36
  curl -fsSL -o config.yaml https://raw.githubusercontent.com/GeiserX/audio-transcode-watcher/main/config.example.yaml
37
37
  docker run -d --name audio_transcoder -e CONFIG_FILE=/app/config.yaml \
38
38
  -v ./config.yaml:/app/config.yaml:ro -v /path/to/flac:/music/flac:ro -v /path/to/mp3:/music/mp3 \
39
- drumsergio/audio-transcoder:0.7.0
39
+ drumsergio/audio-transcoder:0.7.1
40
40
  ```
41
41
 
42
42
  Edit `config.yaml` first so its outputs match the folders you mount; the example writes ALAC, MP3 and AAC. [Getting started](https://github.com/GeiserX/audio-transcode-watcher/blob/main/docs/getting-started.md) has Docker Compose and the full `docker run`.
@@ -1,4 +1,4 @@
1
- # Audio Transcode Watcher Configuration (0.7.0)
1
+ # Audio Transcode Watcher Configuration (0.7.1)
2
2
  # ======================================
3
3
  #
4
4
  # This configuration file defines the source folder and output destinations
@@ -1,6 +1,6 @@
1
1
  # Roadmap
2
2
 
3
- Current version: **0.7.0**
3
+ Current version: **0.7.1**
4
4
 
5
5
  ## Completed
6
6
 
@@ -29,7 +29,7 @@ outputs:
29
29
  ```yaml
30
30
  services:
31
31
  audio-transcoder:
32
- image: drumsergio/audio-transcoder:0.7.0
32
+ image: drumsergio/audio-transcoder:0.7.1
33
33
  container_name: audio_transcoder
34
34
  environment:
35
35
  - TZ=Europe/Madrid
@@ -60,6 +60,6 @@ docker run -d \
60
60
  -v /path/to/flac:/music/flac:ro \
61
61
  -v /path/to/mp3:/music/mp3 \
62
62
  --restart unless-stopped \
63
- drumsergio/audio-transcoder:0.7.0
63
+ drumsergio/audio-transcoder:0.7.1
64
64
  ```
65
65
 
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "audio-transcode-watcher"
7
7
 
8
- version = "0.7.0"
8
+ version = "0.7.1"
9
9
 
10
10
  description = "Watch a source folder and automatically transcode audio files to multiple formats"
11
11
  readme = "README.md"
@@ -1,3 +1,3 @@
1
1
  """Audio Transcode Watcher - Automatic audio file transcoding."""
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.7.1"
@@ -347,8 +347,8 @@ def atomic_ffmpeg_encode(
347
347
  try:
348
348
  if os.path.exists(tmp_dest):
349
349
  os.remove(tmp_dest)
350
- except Exception:
351
- pass
350
+ except OSError as e:
351
+ logger.warning("Could not remove stale temp file %s: %s", tmp_dest, e)
352
352
 
353
353
  # Replace destination with temp path
354
354
  cmd = list(cmd)
@@ -378,12 +378,14 @@ def atomic_ffmpeg_encode(
378
378
  try:
379
379
  finalize(tmp_dest)
380
380
  except Exception as e:
381
- logger.warning("Post-encode step failed for %s: %s", final_dest, e)
381
+ logger.warning(
382
+ "Post-encode step failed for %s: %s", final_dest, e, exc_info=True
383
+ )
382
384
 
383
385
  try:
384
386
  os.replace(tmp_dest, final_dest)
385
387
  return 0
386
- except Exception as e:
388
+ except OSError as e:
387
389
  logger.error("Atomic replace failed for %s: %s", final_dest, e)
388
390
  _cleanup_temp(tmp_dest)
389
391
  return 1
@@ -464,5 +466,5 @@ def _cleanup_temp(path: str) -> None:
464
466
  try:
465
467
  if os.path.exists(path):
466
468
  os.remove(path)
467
- except Exception:
468
- pass
469
+ except OSError as e:
470
+ logger.warning("Could not remove temp file %s: %s", path, e)
@@ -75,7 +75,7 @@ def extract_metadata(filepath: str) -> tuple[str, str] | None:
75
75
  if artist and title:
76
76
  return artist, title
77
77
  except Exception:
78
- logger.debug("Could not read metadata from %s", filepath)
78
+ logger.debug("Could not read metadata from %s", filepath, exc_info=True)
79
79
 
80
80
  # Fallback: parse filename "Artist - Title.ext"
81
81
  stem = Path(filepath).stem
@@ -16,20 +16,22 @@ from .watcher import start_watcher
16
16
 
17
17
  def setup_logging() -> None:
18
18
  """Configure logging for the application."""
19
- # Ensure Unicode output works
19
+ logging.basicConfig(
20
+ level=logging.INFO,
21
+ format="%(asctime)s %(levelname)s: %(message)s",
22
+ datefmt="%H:%M:%S",
23
+ )
24
+
25
+ # Ensure Unicode output works (reconfigure changes the stream in place,
26
+ # so the handler above writes UTF-8 too)
20
27
  try:
21
28
  if hasattr(sys.stdout, "reconfigure"):
22
29
  sys.stdout.reconfigure(encoding="utf-8")
23
30
  if hasattr(sys.stderr, "reconfigure"):
24
31
  sys.stderr.reconfigure(encoding="utf-8")
25
32
  except Exception:
26
- pass
27
-
28
- logging.basicConfig(
29
- level=logging.INFO,
30
- format="%(asctime)s %(levelname)s: %(message)s",
31
- datefmt="%H:%M:%S",
32
- )
33
+ logger = logging.getLogger(__name__)
34
+ logger.warning("Could not switch output to UTF-8", exc_info=True)
33
35
 
34
36
 
35
37
  def main() -> int:
@@ -160,8 +160,12 @@ def process_source_file(
160
160
  _tag_source(source_path, config)
161
161
  if not _process_outputs(source_path, config, force):
162
162
  _remember_failure(source_path)
163
- if config.replaygain and not replaygain.is_checked(source_path):
164
- _carry_replaygain(source_path, config)
163
+ # An output that could not be tagged is tried again next scan.
164
+ if (
165
+ config.replaygain
166
+ and not replaygain.is_checked(source_path)
167
+ and _carry_replaygain(source_path, config)
168
+ ):
165
169
  replaygain.mark_checked(source_path)
166
170
  # Auto-fetch lyrics if enabled and no .lrc sidecar exists
167
171
  if config.fetch_lyrics:
@@ -201,21 +205,25 @@ def _tag_source(source_path: str, config: Config) -> None:
201
205
  manifest.restat(output.path, out_path, before, source_path=source_path)
202
206
 
203
207
 
204
- def _carry_replaygain(source_path: str, config: Config) -> None:
208
+ def _carry_replaygain(source_path: str, config: Config) -> bool:
205
209
  """Give *source_path*'s existing outputs its ReplayGain track tags.
206
210
 
207
211
  Nothing is re-encoded. A copy is copied again, so it stays identical to
208
212
  its source; any other output gets the two tags written into it.
213
+
214
+ Returns False if an output could not be tagged or recopied, so the
215
+ caller leaves the source unchecked and the next scan tries again.
209
216
  """
210
217
  if not is_lossless(source_path) and _has_lossless_source(source_path, config):
211
- return # its outputs belong to the lossless source of the stem
218
+ return True # its outputs belong to the lossless source of the stem
212
219
  try:
213
220
  values = replaygain.read_track_tags(source_path)
214
221
  except Exception as e: # noqa: BLE001 - unreadable means nothing to carry
215
222
  logger.debug("ReplayGain: cannot read %s: %s", source_path, e)
216
- return
223
+ return True
217
224
  if replaygain.GAIN_TAG not in values:
218
- return
225
+ return True
226
+ ok = True
219
227
  for output in config.outputs:
220
228
  filename, action = plan_output(source_path, output)
221
229
  out_path = get_output_file_path(
@@ -231,6 +239,8 @@ def _carry_replaygain(source_path: str, config: Config) -> None:
231
239
  manifest.record(
232
240
  output.path, out_path, config.source_path, source_path, "copy"
233
241
  )
242
+ else:
243
+ ok = False
234
244
  continue
235
245
  before = os.stat(out_path)
236
246
  if replaygain.write_track_tags(out_path, values):
@@ -238,6 +248,8 @@ def _carry_replaygain(source_path: str, config: Config) -> None:
238
248
  logger.info("♫ ReplayGain tags → %s", out_path)
239
249
  except Exception as e: # noqa: BLE001 - one bad output never stops the pass
240
250
  logger.warning("ReplayGain: could not tag %s: %s", out_path, e)
251
+ ok = False
252
+ return ok
241
253
 
242
254
 
243
255
  def _is_known_failure(source_path: str) -> bool:
@@ -367,7 +379,7 @@ def _atomic_copy(source_path: str, out_path: str) -> bool:
367
379
  shutil.copy2(source_path, tmp)
368
380
  os.replace(tmp, out_path)
369
381
  return True
370
- except Exception as e:
382
+ except OSError as e:
371
383
  logger.error("Copy failed %s → %s: %s", source_path, out_path, e)
372
384
  try:
373
385
  if os.path.exists(tmp):
@@ -535,7 +547,7 @@ def delete_outputs(source_path: str, config: Config) -> None:
535
547
  try:
536
548
  logger.info("✘ remove %s", filepath)
537
549
  os.remove(filepath)
538
- except Exception as e:
550
+ except OSError as e:
539
551
  logger.error("Failed to remove %s: %s", filepath, e)
540
552
 
541
553
  # Sidecars are shared by every source of the stem; remove them only
@@ -582,7 +594,7 @@ def sync_sidecars(source_path: str, config: Config) -> None:
582
594
  os.makedirs(os.path.dirname(sidecar_dst), exist_ok=True)
583
595
  shutil.copy2(sidecar_src, sidecar_dst)
584
596
  logger.info("► copy sidecar %s → %s", sidecar_src, sidecar_dst)
585
- except Exception as e:
597
+ except OSError as e:
586
598
  logger.error(
587
599
  "Failed to copy sidecar %s → %s: %s", sidecar_src, sidecar_dst, e
588
600
  )
@@ -606,7 +618,7 @@ def delete_sidecars(source_path: str, config: Config) -> None:
606
618
  try:
607
619
  logger.info("✘ remove sidecar %s", sidecar_path)
608
620
  os.remove(sidecar_path)
609
- except Exception as e:
621
+ except OSError as e:
610
622
  logger.error("Failed to remove sidecar %s: %s", sidecar_path, e)
611
623
 
612
624
 
@@ -637,10 +649,10 @@ def cleanup_stale_temp_files(config: Config) -> int:
637
649
  logger.info("✘ cleanup stale temp %s", full)
638
650
  os.remove(full)
639
651
  cleaned += 1
640
- except Exception as e:
652
+ except OSError as e:
641
653
  logger.error("Failed to remove temp file %s: %s", full, e)
642
- except Exception as e:
643
- logger.error("Failed to scan %s for temp files: %s", output.path, e)
654
+ except Exception:
655
+ logger.exception("Failed to scan %s for temp files", output.path)
644
656
  return cleaned
645
657
 
646
658
 
@@ -663,12 +675,12 @@ def purge_all_outputs(config: Config) -> None:
663
675
  try:
664
676
  logger.info("✘ purge %s", full)
665
677
  os.remove(full)
666
- except Exception as e:
678
+ except OSError as e:
667
679
  logger.error("Failed to purge %s: %s", full, e)
668
680
  manifest.forget(output.path)
669
681
  remove_empty_dirs(output.path)
670
- except Exception as e:
671
- logger.error("Failed to purge folder %s: %s", output.path, e)
682
+ except Exception:
683
+ logger.exception("Failed to purge folder %s", output.path)
672
684
 
673
685
 
674
686
  def initial_sync(config: Config, periodic: bool = False) -> None:
@@ -705,8 +717,8 @@ def initial_sync(config: Config, periodic: bool = False) -> None:
705
717
  # Collect source files recursively
706
718
  try:
707
719
  source_files = walk_audio_files(config.source_path)
708
- except Exception as e:
709
- logger.error("Failed to scan source: %s", e)
720
+ except Exception:
721
+ logger.exception("Failed to scan source")
710
722
  return
711
723
 
712
724
  # Process all source files in parallel (skip stability check - files are on disk)
@@ -718,8 +730,8 @@ def initial_sync(config: Config, periodic: bool = False) -> None:
718
730
  def process_one(src_file: str) -> None:
719
731
  try:
720
732
  process_source_file(src_file, config, force=False, check_stable=False)
721
- except Exception as e:
722
- logger.error("Error processing %s: %s", src_file, e)
733
+ except Exception:
734
+ logger.exception("Error processing %s", src_file)
723
735
 
724
736
  with ThreadPoolExecutor(max_workers=workers) as executor:
725
737
  futures = [executor.submit(process_one, f) for f in source_files]
@@ -762,8 +774,8 @@ def _cleanup_orphans(config: Config) -> None:
762
774
  src_root = config.source_path
763
775
  try:
764
776
  source_files = walk_audio_files(src_root)
765
- except Exception as e:
766
- logger.error("Failed to scan source for orphan cleanup: %s", e)
777
+ except Exception:
778
+ logger.exception("Failed to scan source for orphan cleanup")
767
779
  return
768
780
  if not source_files:
769
781
  logger.warning(
@@ -801,7 +813,7 @@ def _cleanup_orphans(config: Config) -> None:
801
813
  try:
802
814
  logger.info("✘ remove %s %s", kind, full)
803
815
  os.remove(full)
804
- except Exception as e:
816
+ except OSError as e:
805
817
  logger.error("Failed to remove %s: %s", full, e)
806
818
 
807
819
  for output in config.outputs:
@@ -831,8 +843,8 @@ def _cleanup_orphans(config: Config) -> None:
831
843
  logger.debug("Keeping young or in-progress %s", full)
832
844
  continue
833
845
  remove(full, kind)
834
- except Exception as e:
835
- logger.error("Failed to scan %s for orphans: %s", output.path, e)
846
+ except Exception:
847
+ logger.exception("Failed to scan %s for orphans", output.path)
836
848
 
837
849
  # Remove empty subdirectories left after orphan cleanup, and forget
838
850
  # manifest rows whose output is gone
@@ -2,11 +2,14 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import logging
5
6
  import os
6
7
  import time
7
8
  import unicodedata
8
9
  from pathlib import Path
9
10
 
11
+ logger = logging.getLogger(__name__)
12
+
10
13
  # Audio file extensions considered as source files
11
14
  LOSSLESS_EXTENSIONS = {
12
15
  ".flac",
@@ -121,6 +124,7 @@ def appears_empty_dir(path: str) -> bool:
121
124
  return True
122
125
  except Exception:
123
126
  # On any error, treat as empty to be safe
127
+ logger.debug("Cannot list %s, treating it as empty", path, exc_info=True)
124
128
  return True
125
129
 
126
130
 
@@ -503,6 +503,49 @@ class TestCarryEdges:
503
503
  assert "could not tag" in caplog.text
504
504
  assert abs(_gain(tmp_path / "mp3" / "a.mp3") - EXPECTED_GAIN) < 0.5
505
505
 
506
+ @pytest.mark.skipif(
507
+ hasattr(os, "geteuid") and os.geteuid() == 0,
508
+ reason="root writes through a read-only mode",
509
+ )
510
+ def test_unwritable_output_is_retried_on_the_next_scan(self, tmp_path, caplog):
511
+ src = tmp_path / "src"
512
+ _tone(src / "a.flac")
513
+ config = _config(src, {"alac": "", "mp3": ""}, tmp_path, rg=False)
514
+ initial_sync(config)
515
+ alac = tmp_path / "alac" / "a.m4a"
516
+ alac.chmod(0o444) # an output the service cannot write, as root-owned
517
+ config.replaygain = True
518
+ try:
519
+ initial_sync(config, periodic=True)
520
+ assert f"could not tag {alac}" in caplog.text
521
+ assert replaygain.read_track_tags(str(alac)) == {}
522
+ assert abs(_gain(tmp_path / "mp3" / "a.mp3") - EXPECTED_GAIN) < 0.5
523
+
524
+ caplog.clear()
525
+ initial_sync(config, periodic=True) # still read-only: warned again
526
+ assert f"could not tag {alac}" in caplog.text
527
+ finally:
528
+ alac.chmod(0o644)
529
+
530
+ caplog.clear()
531
+ initial_sync(config, periodic=True)
532
+ assert "could not tag" not in caplog.text
533
+ assert abs(_gain(alac) - EXPECTED_GAIN) < 0.5
534
+ assert replaygain.is_checked(str(src / "a.flac"))
535
+
536
+ def test_failed_recopy_is_retried_on_the_next_scan(self, tmp_path):
537
+ src = tmp_path / "src"
538
+ mp3 = _tone(src / "a.mp3", "-c:a", "libmp3lame")
539
+ config = _config(src, {"alac": ""}, tmp_path, rg=False)
540
+ initial_sync(config)
541
+ config.replaygain = True
542
+ with patch.object(sync_mod, "_atomic_copy", return_value=False):
543
+ initial_sync(config, periodic=True)
544
+ assert not replaygain.is_checked(str(mp3))
545
+ initial_sync(config, periodic=True)
546
+ assert filecmp.cmp(mp3, tmp_path / "alac" / "a.mp3", shallow=False)
547
+ assert replaygain.is_checked(str(mp3))
548
+
506
549
  def test_tagging_error_never_blocks_the_encode(self, tmp_path, caplog):
507
550
  src = tmp_path / "src"
508
551
  _tone(src / "a.flac")
@@ -4,7 +4,7 @@ requires-python = ">=3.14"
4
4
 
5
5
  [[package]]
6
6
  name = "audio-transcode-watcher"
7
- version = "0.7.0"
7
+ version = "0.7.1"
8
8
  source = { editable = "." }
9
9
  dependencies = [
10
10
  { name = "mutagen" },