feat(media): chaptarr hardlinks + keeps its own ebook copy
Chaptarr had /downloads, /ebooks and /audiobooks as separate bind mounts, so hardlinks failed with EXDEV and every import was a full copy (each seeding audiobook stored twice). Mount /storage1 once and symlink the old container paths into it via an entrypoint wrapper, so nothing in chaptarr's DB changes. /ebooks now points at /storage1/Media/Ebooks, chaptarr's own ebook folder. A Custom Script hook hardlinks each new ebook into the CWA ingest folder, so CWA deleting its ingest copy no longer makes chaptarr think the book is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
417cd3165f
commit
5d70a4e825
4 files changed
+73
-8
No files matched your search
+11
-3
@@ -5,7 +5,7 @@ Lives in the `media` stack. Flow:
|
|||||||
```
|
```
|
||||||
prowlarr ─► chaptarr ─► qbittorrent / nzbget ─► /storage1/complete
|
prowlarr ─► chaptarr ─► qbittorrent / nzbget ─► /storage1/complete
|
||||||
│
|
│
|
||||||
├─ ebooks ─► /storage1/complete/books-ingest ─► CWA ─► /storage1/Media/Books (Calibre lib) ─► Send-to-Kindle / OPDS
|
├─ ebooks ─► /storage1/Media/Ebooks (chaptarr's copy) ─cwa-ingest.sh hardlink─► /storage1/complete/books-ingest ─► CWA ─► /storage1/Media/Books (Calibre lib) ─► Send-to-Kindle / OPDS
|
||||||
└─ audiobooks ─► /storage1/Media/Audiobooks ─► audiobookshelf
|
└─ audiobooks ─► /storage1/Media/Audiobooks ─► audiobookshelf
|
||||||
storyteller reads both libraries :ro ─► /storage1/labdata/storyteller (aligned EPUB 3 + media overlays)
|
storyteller reads both libraries :ro ─► /storage1/labdata/storyteller (aligned EPUB 3 + media overlays)
|
||||||
```
|
```
|
||||||
@@ -52,8 +52,8 @@ sudo chown -R 1000:1000 /config/chaptarr /config/calibre-web-automated /config/a
|
|||||||
|
|
||||||
## 3. Post-deploy checklist
|
## 3. Post-deploy checklist
|
||||||
|
|
||||||
- [ ] **chaptarr:** set the admin login on first launch. Add root folders `/ebooks` (ebook) and `/audiobooks` (audiobook).
|
- [ ] **chaptarr:** set the admin login on first launch. Add root folders `/ebooks` (ebook) and `/audiobooks` (audiobook). These are symlinks into the `/storage1` mount; see *Hardlinks* below.
|
||||||
- [ ] **chaptarr:** turn on *Unmonitor Deleted Books* (Media Management). CWA deletes files from `/ebooks` after ingest, and without this setting chaptarr will try to grab them again.
|
- [x] ~~**chaptarr:** turn on *Unmonitor Deleted Books*~~. This is obsolete since 2026-12-03: CWA no longer deletes chaptarr's ebooks, because chaptarr keeps its own copy in `/storage1/Media/Ebooks`.
|
||||||
- [ ] **Prowlarr → chaptarr app sync:** in Prowlarr, go to Settings → Apps → add Chaptarr (or Readarr if Chaptarr isn't listed yet). Use `http://prowlarr:9696` and `http://chaptarr:8789`, plus the chaptarr API key. Sync, then confirm the indexers show up in chaptarr.
|
- [ ] **Prowlarr → chaptarr app sync:** in Prowlarr, go to Settings → Apps → add Chaptarr (or Readarr if Chaptarr isn't listed yet). Use `http://prowlarr:9696` and `http://chaptarr:8789`, plus the chaptarr API key. Sync, then confirm the indexers show up in chaptarr.
|
||||||
- [ ] **Download clients in chaptarr:** add `qbittorrent:3232` with category `books`, and `nzbget:6789` with category `books`. Both write under `/downloads` on the same `/storage1/complete` mount, so no remote path mapping is needed. Check that the `books` categories exist in both clients.
|
- [ ] **Download clients in chaptarr:** add `qbittorrent:3232` with category `books`, and `nzbget:6789` with category `books`. Both write under `/downloads` on the same `/storage1/complete` mount, so no remote path mapping is needed. Check that the `books` categories exist in both clients.
|
||||||
- [ ] **CWA:** log in as `admin` / `admin123` and change the password right away. The library path is `/calibre-library`. Drop a test EPUB into `/storage1/complete/books-ingest` and confirm it shows up in the library and leaves the ingest folder.
|
- [ ] **CWA:** log in as `admin` / `admin123` and change the password right away. The library path is `/calibre-library`. Drop a test EPUB into `/storage1/complete/books-ingest` and confirm it shows up in the library and leaves the ingest folder.
|
||||||
@@ -62,6 +62,14 @@ sudo chown -R 1000:1000 /config/chaptarr /config/calibre-web-automated /config/a
|
|||||||
- [ ] **storyteller:** create an admin and point the import at `/libraries/books` and `/libraries/audiobooks`. Run one test alignment on a short book (whisper runs on CPU, so this is slow). Open the result in the Storyteller Reader app.
|
- [ ] **storyteller:** create an admin and point the import at `/libraries/books` and `/libraries/audiobooks`. Run one test alignment on a short book (whisper runs on CPU, so this is slow). Open the result in the Storyteller Reader app.
|
||||||
- [ ] **uptime-kuma:** add monitors for the four new hosts.
|
- [ ] **uptime-kuma:** add monitors for the four new hosts.
|
||||||
|
|
||||||
|
## Hardlinks + chaptarr's ebook copy (2026-12-03)
|
||||||
|
|
||||||
|
- Chaptarr mounts `/storage1` **once**. `chaptarr/start.sh` (the entrypoint wrapper) symlinks `/downloads`, `/audiobooks` and `/ebooks` into it. With separate bind mounts, `link()` fails with EXDEV and chaptarr silently copied every import instead, so seeding audiobooks existed twice. The container paths didn't change, so chaptarr's DB needed no migration.
|
||||||
|
- `/ebooks` → `/storage1/Media/Ebooks` is chaptarr's own ebook folder (it used to be the CWA ingest folder, which CWA empties, so chaptarr thought every ebook was missing).
|
||||||
|
- Connect → Custom Script **"CWA ingest"** (`/scripts/cwa-ingest.sh`, On Import + On Upgrade) hardlinks each newly imported ebook into `/storage1/complete/books-ingest/<Author>/`. CWA deletes its link after ingest, and chaptarr's file remains.
|
||||||
|
- Existing Calibre books were backfilled by hardlinking them from `/storage1/Media/Books` into `/storage1/Media/Ebooks/<Author>/` and rescanning.
|
||||||
|
- Hardlinks share content, so never edit files in `/storage1/Media/Ebooks` in place (e.g. chaptarr metadata writing). That would also change Calibre's copy of a backfilled book.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- `STORYTELLER_SECRET_KEY` is in `stack.env` (`secrets.token_hex(64)`). If you rotate it, every Storyteller session is logged out.
|
- `STORYTELLER_SECRET_KEY` is in `stack.env` (`secrets.token_hex(64)`). If you rotate it, every Storyteller session is logged out.
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Chaptarr Connect → Custom Script ("CWA ingest"), On Import + On Upgrade.
|
||||||
|
#
|
||||||
|
# Chaptarr keeps its own ebook copy in /ebooks (= /storage1/Media/Ebooks) so it can see what
|
||||||
|
# it already has. This hands CWA a *hardlink* of each newly imported ebook through the ingest
|
||||||
|
# folder. CWA deletes its link once it has added the book to Calibre, and chaptarr's file is
|
||||||
|
# left alone.
|
||||||
|
[ "$Chaptarr_EventType" = "Download" ] || exit 0 # also covers the "Test" button
|
||||||
|
|
||||||
|
INGEST=/storage1/complete/books-ingest
|
||||||
|
|
||||||
|
IFS='|'
|
||||||
|
for p in $Chaptarr_AddedBookPaths $Chaptarr_BookFile_Path; do
|
||||||
|
case "$p" in
|
||||||
|
/ebooks/*) rel=${p#/ebooks/} ;;
|
||||||
|
/storage1/Media/Ebooks/*) rel=${p#/storage1/Media/Ebooks/} ;;
|
||||||
|
*) continue ;; # audiobooks etc.
|
||||||
|
esac
|
||||||
|
[ -f "$p" ] || continue
|
||||||
|
author=${rel%%/*}
|
||||||
|
dest="$INGEST/$author/$(basename "$p")"
|
||||||
|
[ -e "$dest" ] && continue # already queued (path listed twice)
|
||||||
|
mkdir -p "$INGEST/$author"
|
||||||
|
ln "$p" "$dest" 2>/dev/null || cp "$p" "$dest"
|
||||||
|
echo "cwa-ingest: queued $p"
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Chaptarr entrypoint wrapper (compose: entrypoint: /scripts/start.sh).
|
||||||
|
#
|
||||||
|
# /storage1 is mounted ONCE; /downloads, /audiobooks and /ebooks are symlinks into it.
|
||||||
|
# Separate bind mounts make link() fail with EXDEV, and chaptarr silently falls back to a
|
||||||
|
# full copy, so every seeding audiobook used to exist twice on disk. One mount → real hardlinks.
|
||||||
|
# The container paths stay the same, so nothing in chaptarr's DB had to change.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
link() { # $1 = container path, $2 = target under /storage1
|
||||||
|
if [ -L "$1" ]; then
|
||||||
|
ln -sfn "$2" "$1"
|
||||||
|
elif [ -d "$1" ]; then
|
||||||
|
rmdir "$1" # fails loudly if something unexpected is in there
|
||||||
|
ln -s "$2" "$1"
|
||||||
|
else
|
||||||
|
ln -s "$2" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
link /downloads /storage1/complete
|
||||||
|
link /audiobooks /storage1/Media/Audiobooks
|
||||||
|
link /ebooks /storage1/Media/Ebooks
|
||||||
|
|
||||||
|
exec /entrypoint.sh "$@"
|
||||||
@@ -251,8 +251,12 @@ services:
|
|||||||
|
|
||||||
# ============================================================ BOOKS
|
# ============================================================ BOOKS
|
||||||
# Prowlarr -> chaptarr -> qbittorrent/nzbget (/storage1/complete). Chaptarr
|
# Prowlarr -> chaptarr -> qbittorrent/nzbget (/storage1/complete). Chaptarr
|
||||||
# imports ebooks into the CWA ingest folder (CWA owns the Calibre library and
|
# keeps its own ebook copy in /storage1/Media/Ebooks (so it knows what it has)
|
||||||
# deletes ingested files) and audiobooks straight into the ABS library.
|
# and its Custom Script hook (chaptarr/cwa-ingest.sh) hardlinks each new ebook
|
||||||
|
# into the CWA ingest folder (CWA owns the Calibre library and deletes ingested
|
||||||
|
# files). Audiobooks go straight into the ABS library.
|
||||||
|
# /storage1 is mounted once and chaptarr/start.sh symlinks /downloads,
|
||||||
|
# /audiobooks, /ebooks into it — separate bind mounts break hardlinks (EXDEV).
|
||||||
# Storyteller reads both libraries read-only and writes aligned EPUBs to its
|
# Storyteller reads both libraries read-only and writes aligned EPUBs to its
|
||||||
# own /data. Readarr is retired upstream — do not add it.
|
# own /data. Readarr is retired upstream — do not add it.
|
||||||
chaptarr:
|
chaptarr:
|
||||||
@@ -266,11 +270,12 @@ services:
|
|||||||
nofile: { soft: 65536, hard: 65536 }
|
nofile: { soft: 65536, hard: 65536 }
|
||||||
environment:
|
environment:
|
||||||
- UMASK=002
|
- UMASK=002
|
||||||
|
entrypoint: ["/bin/sh", "/scripts/start.sh"]
|
||||||
|
command: ["dotnet", "/app/Chaptarr.dll", "-nobrowser", "-data=/config"]
|
||||||
volumes:
|
volumes:
|
||||||
- /config/chaptarr:/config
|
- /config/chaptarr:/config
|
||||||
- /storage1/complete:/downloads
|
- /storage1:/storage1
|
||||||
- /storage1/complete/books-ingest:/ebooks
|
- ./chaptarr:/scripts:ro
|
||||||
- /storage1/Media/Audiobooks:/audiobooks
|
|
||||||
ports:
|
ports:
|
||||||
- "8789:8789"
|
- "8789:8789"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user