Skip to content

make audiobook organization recursive#56

Merged
JeremiahM37 merged 2 commits into
JeremiahM37:mainfrom
sgerner:codex/recursive-audiobook-import
Jun 2, 2026
Merged

make audiobook organization recursive#56
JeremiahM37 merged 2 commits into
JeremiahM37:mainfrom
sgerner:codex/recursive-audiobook-import

Conversation

@sgerner

@sgerner sgerner commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This change makes audiobook organization preserve nested directory trees instead of flattening only the top level.

What changed:

  • Added a recursive directory mover for audiobook imports.
  • Kept the existing single-file audiobook path unchanged.
  • Added regression coverage for a nested CD1/ and CD2/Extras/ layout.
  • Preserved the guard that avoids creating an empty destination directory when the source path is missing.

Why:

  • Some audiobook torrents contain nested disc or extras folders.
  • The previous implementation only moved direct children and did not recurse, which broke those imports.

Validation:

  • go test ./internal/organize
  • Rebuilt the local librarr:prowlarr-audiobooks image.
  • Recreated the running librarr container.

@sgerner sgerner marked this pull request as ready for review June 1, 2026 00:53
Comment thread internal/organize/pipeline.go Dismissed
Comment thread internal/organize/pipeline.go Dismissed
Comment thread internal/organize/pipeline.go Dismissed
Comment thread internal/organize/pipeline.go Dismissed
Comment thread internal/organize/pipeline.go Dismissed
@JeremiahM37 JeremiahM37 self-assigned this Jun 1, 2026

@JeremiahM37 JeremiahM37 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recursive mover looks good. Two things:

  1. One symlink concern inline.
  2. This branch is stacked on #52 — the audiobookbay.go and audiobookbay_test.go diffs in this PR are the same as #52's. Once #52 lands please rebase onto main so that delta falls out.

return os.Remove(src)
}

func moveDirTree(srcDir, dstDir string) error {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WalkDir doesn't follow directory symlinks (good), but a symlinked file inside a torrent will get dereferenced by moveFile's copy+delete fallback — that path uses ReadFile/WriteFile, so a symlink pointing at /etc/passwd would get copied into the audiobook library. Worth a d.Type()&os.ModeSymlink != 0 skip in the walk before moveFile is called.

@sgerner sgerner force-pushed the codex/recursive-audiobook-import branch from 1cda863 to 3875d9e Compare June 1, 2026 05:07
Comment thread internal/organize/pipeline.go Dismissed
@JeremiahM37 JeremiahM37 merged commit 82264b4 into JeremiahM37:main Jun 2, 2026
4 checks passed
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.

3 participants