Skip to content

feat(sync): let ignored paths stay untouched in the outputs, so a second Syncthing connection keeps its files - #56

Merged
GeiserX merged 2 commits into
mainfrom
feat/keep-ignored-in-outputs
Nov 25, 2026
Merged

GeiserX merged 2 commits into
mainfrom
feat/keep-ignored-in-outputs

Conversation

@GeiserX

@GeiserX GeiserX commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Problem

Since 0.8.0 (#52), ignored_files makes the listed paths count as absent from the source. The cleanup in each output folder then removes audio and .lrc files that no source accounts for, and empty folders, anywhere in the output.

When a second Syncthing connection syncs an output folder, it keeps its own .stfolder, .stignore and .stversions there. The cleanup removes that connection's versions and its empty .stfolder marker, and Syncthing stops a folder whose marker is missing. Closes #55.

Fix

A new key, settings.ignored_files_in_outputs, takes true or false. The default is false.

When it is true, the same ignored_files entries also match paths relative to each output folder. The rules are the same as on the source side:

  • An entry starts at the top of the folder.
  • **/ matches at any depth.
  • *, ? and [...] work as patterns.
  • Matching is case-sensitive, with names compared in NFC form.
settings:
  ignored_files:
    - ".stfolder"
    - ".stignore"
    - "**/.stversions"
    - "**/.syncthing.*"
  ignored_files_in_outputs: true

What the key protects:

  • A matching folder protects everything in it, and it stays even when it is empty.
  • An entry that names a file protects only files the watcher does not write itself. Audio, .lrc, .tmp__ff and manifest files are protected only through a matching folder, so **/*.wav never freezes a WAV output.
  • These steps leave protected paths alone:
    • the orphan cleanup
    • the empty-folder cleanup
    • the cleanup after a source folder is deleted or moved
    • force_reencode
    • the stale temp sweep
  • The write paths need no guard. A kept source's output path has the same folder parts as the source, so a matching folder would also have made the source ignored. A unit test pins this.

With the key unset or false, nothing changes.

Verification

  • The suite has 631 tests and all pass. The 590 existing tests are unchanged.
  • 34 of the new tests fail on main, and the controls pass on both main and the branch.
  • ruff check and ruff format --check are clean.
  • Positive controls make the main test fail, so the tests can catch a regression. Each control removes one guard: the folder prune, the keep argument, or the **/.syncthing.* entry.
  • I ran the real entry point on a copy of this setup. Each side had its own Syncthing files: .stfolder with and without its marker file, .stignore, and .stversions with versioned audio and .lrc. The output also had .syncthing.*.tmp files. The run covered:
    • a startup sync and periodic syncs
    • 13 watcher events
    • a sync after every file was past the orphan age limit
    • a restart with force_reencode
  • Without the key, three configs give the same result on main and on the branch:
    • the file trees and their SHA-256 sums
    • the changes after each step
    • the manifest rows
    • the INFO and WARNING log lines
  • With the key on, no Syncthing file or folder was removed.

Summary by CodeRabbit

  • New Features
    • Added the ignored_files_in_outputs setting, disabled by default. When enabled, matching folders in output locations and their contents are preserved during syncing, cleanup, and forced re-encoding.
    • Audio and subtitle files are protected when they are inside a matching folder; matching their filenames alone does not protect them.
  • Documentation
    • Updated configuration and behavior guides with the setting’s default, matching rules, and cleanup effects.

…ond sync tool can keep its files there

Since 0.8.0 the orphan pass treats ignored sources as absent, and it has
always removed unaccounted audio and .lrc files and empty folders anywhere
in an output. A second Syncthing connection on an output folder keeps its
own .stfolder, .stignore and .stversions there, and loses its versions and
its folder marker to that cleanup.

settings.ignored_files_in_outputs (default false) makes the ignored_files
entries also match paths relative to each output folder. A matching folder,
and everything in it, is skipped by the orphan cleanup, the empty-folder
cleanup, a source folder delete, force_reencode and the stale temp sweep.
Files the watcher writes itself (audio, .lrc, .tmp__ff, the manifest) are
protected only through a matching folder, so an entry such as **/*.wav
never freezes a WAV output. With the key unset nothing changes.

Closes #55
…puts example

The example for ignored_files_in_outputs listed only .stfolder, .stignore
and .stversions. A second Syncthing connection also writes
.syncthing.<name>.tmp files next to the files it downloads, in any folder
of the output. A force_reencode purge or the cleanup after a source folder
is deleted still removed those, so a user who copied the example did not
get an output that is fully left alone. The example now adds
"**/.syncthing.*", and tests pin that this entry keeps the temp files
through a purge and a source folder delete.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds the ignored_files_in_outputs setting, defaulting to false. When enabled, matching output folders and their contents are preserved during selected sync cleanup and directory-deletion operations.

Changes: Output Path Protection

Layer / File(s) Summary
Configuration and path matching
src/audio_transcode_watcher/config.py, src/audio_transcode_watcher/sync.py, src/audio_transcode_watcher/utils.py, tests/test_config.py, tests/test_ignored_in_outputs.py, tests/test_utils.py, config.example.yaml, docs/configuration.md
Adds and validates ignored_files_in_outputs, defines output-path matching, and adds a callback to preserve selected directories during empty-directory cleanup. Tests cover defaults, validation, path matching, and the callback.
Sync cleanup filtering
src/audio_transcode_watcher/sync.py, tests/test_ignored_in_outputs.py, tests/test_utils.py, CHANGELOG.md, docs/configuration.md, docs/how-it-works.md
Applies output-folder protection to stale-temp, forced-purge, orphan, and empty-directory cleanup. Tests cover protected and unprotected paths. Documentation describes the setting and its cleanup scope.
Directory deletion filtering
src/audio_transcode_watcher/watcher.py, tests/test_watcher.py
Directory-deletion cleanup skips protected folders and files when the setting is enabled. Tests also cover the existing full-removal behavior when it is disabled.

Estimated code review effort: 3 (Moderate) | ~22 minutes

Change: Feature · Severity of issue fixed: Medium

Possibly related PRs

Merge Risk: Minimal · up to a6ab9

This adds an opt-in setting that leaves matching output paths alone during cleanup. Behavior is unchanged when the setting is off, and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: an opt-in setting (settings.ignored_files_in_outputs) that keeps ignored paths untouched in output folders. The raw summary and objectives confirm this is the core cha…
Linked Issues check Passed Directly linked issue #55 asks that ignored files stay ignored in both source and output, and that output-side Syncthing files (.stfolder, .stignore, .stversions) survive cleanup. The PR adds settings…
Out of Scope Changes check Passed All changed areas connect to #55 or support its implementation. Core code: config.py (new boolean key with validation), sync.py (output protection and cleanup guards), utils.py (keep callback for remo…
Full details: Title check

Explanation

The title names the main change: an opt-in setting (settings.ignored_files_in_outputs) that keeps ignored paths untouched in output folders. The raw summary and objectives confirm this is the core change across config, sync, utils, watcher, docs, and tests. The title's Syncthing motivation matches linked issue #55. The title is 109 characters, longer than ideal, but it is specific and accurate.

Full details: Linked Issues check

Explanation

Directly linked issue #55 asks that ignored files stay ignored in both source and output, and that output-side Syncthing files (.stfolder, .stignore, .stversions) survive cleanup. The PR adds settings.ignored_files_in_outputs (default false). When true, ignored_files entries also match paths relative to each output folder. The summary states that sync.py (kept_in_output, output_keeper) skips matching folders and files during stale-temp cleanup, forced purge, orphan removal, and empty-directory removal. utils.remove_empty_dirs gains a keep callback, and watcher._handle_directory_delete uses it. Matching folders are kept even when empty. Tests cover these paths, including directory deletion with the setting on and off. The issue's alternatives (local fork, .atwignore) are not required. Scope of the evidence: this assessment relies on the PR summary and PR description. I did not run a focused source inspection of sync.py, so the exact guard logic is taken from the summary. The requirement is met under the opt-in setting; with the default false, output cleanup still removes such files, as the issue's scenario implies for the opt-out case.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to #55 or support its implementation. Core code: config.py (new boolean key with validation), sync.py (output protection and cleanup guards), utils.py (keep callback for remove_empty_dirs), and watcher.py (directory-delete path using the keep predicate). Tests: test_config.py, test_ignored_in_outputs.py, test_utils.py, and test_watcher.py cover the new behavior. Documentation and examples: CHANGELOG.md, config.example.yaml, docs/configuration.md, and docs/how-it-works.md describe the new key. The example addition of "**/.syncthing.*" matches the Syncthing temp-file case in #55's pipeline. No unrelated refactor or feature was identified in the summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between adfbf75 and a6ab913.

Files selected for processing: 12

  • CHANGELOG.md
  • config.example.yaml
  • docs/configuration.md
  • docs/how-it-works.md
  • src/audio_transcode_watcher/config.py
  • src/audio_transcode_watcher/sync.py
  • src/audio_transcode_watcher/utils.py
  • src/audio_transcode_watcher/watcher.py
  • tests/test_config.py
  • tests/test_ignored_in_outputs.py
  • tests/test_utils.py
  • tests/test_watcher.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.47%. Comparing base (adfbf75) to head (a6ab913).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #56      +/-   ##
==========================================
+ Coverage   96.40%   96.47%   +0.07%     
==========================================
  Files          10       10              
  Lines        1750     1786      +36     
  Branches      352      363      +11     
==========================================
+ Hits         1687     1723      +36     
  Misses         33       33              
  Partials       30       30              
Files with missing lines Coverage Δ
src/audio_transcode_watcher/config.py 100.00% <100.00%> (ø)
src/audio_transcode_watcher/sync.py 95.34% <100.00%> (+0.21%) ⬆️
src/audio_transcode_watcher/utils.py 97.93% <100.00%> (ø)
src/audio_transcode_watcher/watcher.py 97.39% <100.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GeiserX
GeiserX merged commit 4d8c24b into main Nov 25, 2026
6 checks passed
@GeiserX
GeiserX deleted the feat/keep-ignored-in-outputs branch November 25, 2026 12:43
GeiserX added a commit that referenced this pull request Nov 25, 2026
…n the output folders (#57)

Moves the version to 0.9.0 and dates the CHANGELOG for #56, with thanks to @delete-44 for the report in #55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignored files being garbage swept breaks them

1 participant