Skip to content

Add 'Send to root' option to bypass folder template#14

Merged
osteotek merged 2 commits intocrosspoint-reader:masterfrom
Antoinevdlb:feature/send-to-root
Apr 21, 2026
Merged

Add 'Send to root' option to bypass folder template#14
osteotek merged 2 commits intocrosspoint-reader:masterfrom
Antoinevdlb:feature/send-to-root

Conversation

@Antoinevdlb
Copy link
Copy Markdown
Contributor

@Antoinevdlb Antoinevdlb commented Feb 25, 2026

Summary

  • Adds a new "Send to root (ignore folder template)" checkbox in plugin settings
  • When enabled, books are uploaded directly to the configured upload path instead of subdirectories based on Calibre's send template (e.g., /Author Name/Book Title.epub)

Motivation

Some users prefer a flat file structure on their device rather than having books organized into author/title subdirectories. This option allows bypassing the template formatting entirely.

Changes

  • config.py: Added send_to_root preference with UI checkbox
  • driver.py: Skip _format_upload_path() when preference is enabled

Test plan

  • Install plugin in Calibre
  • Open Preferences > Plugins > CrossPoint Reader > Configure
  • Verify "Send to root" checkbox appears
  • With option disabled: send a book, verify it goes to /Author/Title.epub
  • With option enabled: send a book, verify it goes directly to /Title.epub

/!\ I built this with Claude Code. This works, but please don't trust this code as is!

When enabled, books are uploaded directly to the configured upload path
instead of being placed in subdirectories based on Calibre's send template
(e.g., /Author Name/Book Title.epub).

This is useful for devices or workflows that prefer a flat file structure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dff49c3b-ddc0-4632-bf01-74470cb0f265

📥 Commits

Reviewing files that changed from the base of the PR and between 12befdd and 2a9fcea.

📒 Files selected for processing (2)
  • crosspoint_reader/config.py
  • crosspoint_reader/driver.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • crosspoint_reader/driver.py
  • crosspoint_reader/config.py

📝 Walkthrough

Walkthrough

Adds a new preference send_to_root (default False) and a UI checkbox to control it; upload path formatting in upload_books is now skipped when PREFS['send_to_root'] is True, causing files to be sent to the normalized base path without metadata-driven subfolders.

Changes

Cohort / File(s) Summary
Configuration & UI
crosspoint_reader/config.py
Added PREFS.defaults['send_to_root'] = False; added a QCheckBox ("Send to root (ignore folder template)") to CrossPointConfigWidget, initialized from PREFS and persisted via save().
Driver Logic
crosspoint_reader/driver.py
In upload_books, path formatting via _format_upload_path(...) is now skipped when PREFS['send_to_root'] is True, leaving subdirs empty so uploads use the normalized base_path directly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a 'Send to root' option to bypass folder template. It directly corresponds to the primary functionality added across the changeset.
Description check ✅ Passed The description is comprehensive and directly related to the changeset. It explains the feature motivation, outlines the specific files changed, and provides a detailed test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crosspoint_reader/driver.py (1)

277-305: Cache PREFS['send_to_root'] before the loop for consistency.

Every other PREFS read in upload_books (lines 278–285 — host, port, upload_path, chunk_size, debug) is cached as a local variable before the loop. Reading PREFS['send_to_root'] inside the loop on every iteration is inconsistent with that pattern.

♻️ Proposed refactor
         debug = PREFS['debug']
+        send_to_root = PREFS['send_to_root']

         # Normalize base upload path
         ...
         subdirs = []
-        if metadata and i < len(metadata) and not PREFS['send_to_root']:
+        if metadata and i < len(metadata) and not send_to_root:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crosspoint_reader/driver.py` around lines 277 - 305, In upload_books, cache
PREFS['send_to_root'] into a local variable before the loop (e.g., send_to_root
= PREFS['send_to_root']) and replace the in-loop references to
PREFS['send_to_root'] with that local variable; update any conditional that
currently reads PREFS['send_to_root'] (inside the for i, (infile, name) in
enumerate(...) loop) to use the cached send_to_root to ensure consistency with
how host/port/upload_path/chunk_size/debug are handled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crosspoint_reader/driver.py`:
- Around line 277-305: In upload_books, cache PREFS['send_to_root'] into a local
variable before the loop (e.g., send_to_root = PREFS['send_to_root']) and
replace the in-loop references to PREFS['send_to_root'] with that local
variable; update any conditional that currently reads PREFS['send_to_root']
(inside the for i, (infile, name) in enumerate(...) loop) to use the cached
send_to_root to ensure consistency with how
host/port/upload_path/chunk_size/debug are handled.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07e9f20 and 12befdd.

📒 Files selected for processing (2)
  • crosspoint_reader/config.py
  • crosspoint_reader/driver.py
📜 Review details
🔇 Additional comments (2)
crosspoint_reader/config.py (1)

26-79: LGTM — clean, consistent addition following existing patterns.

Default is False, preserving backward-compatible behavior. Widget lifecycle (create → init → layout → save) mirrors fetch_metadata exactly.

crosspoint_reader/driver.py (1)

24-24: Version bump to (0, 2, 0) is appropriate.

New user-visible feature warrants a minor version increment.

@Antoinevdlb
Copy link
Copy Markdown
Contributor Author

Part of the motivation also comes from Crosspoint imminent support of a thumbnail library view - in which case a flat folder structure is beneficial as well.

@Antoinevdlb
Copy link
Copy Markdown
Contributor Author

Any thoughts or concerns here?

@itsthisjustin
Copy link
Copy Markdown
Collaborator

@Antoinevdlb so sorry I just now saw this. Are you ready for it be merged? I agree with intent here. I also happen to want this to work this way.

@Antoinevdlb
Copy link
Copy Markdown
Contributor Author

I was traveling sorry! I am ready to be merged but it seems like there are conflicts now.

@Antoinevdlb
Copy link
Copy Markdown
Contributor Author

Actually conflicts are only extension version, it seems good to go

@osteotek osteotek merged commit 1e33490 into crosspoint-reader:master Apr 21, 2026
1 check 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