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>
28 lines
993 B
Bash
28 lines
993 B
Bash
#!/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
|