Handle unreadable archives and adjust cron job configuration

- Skip page count assignment for corrupt or incompatible archives in comic processing.
- Update `Dockerfile` to append crontab entries to `/etc/crontab` instead of `/etc/cron.daily/cbreader`.
- Modify crontab entry to use the virtual environment's Python binary and include the `root` user for execution.
This commit is contained in:
ajurna committed 2026-10-13 09:46:26 +01:00
1 parent 1bbe0071a0
commit 9b9db755e6
3 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -31,6 +31,6 @@ RUN cd frontend \
&& rm -r node_modules && rm -r node_modules
RUN cat /src/cbreader/crontab >> /etc/cron.daily/cbreader RUN cat /src/cbreader/crontab >> /etc/crontab
EXPOSE 8000 EXPOSE 8000
+1 -1
View File
@@ -1 +1 @@
*/15 * * * * python /src/manage.py scan_comics --settings=cbreader.settings.base */15 * * * * root /src/.venv/bin/python /src/manage.py scan_comics --settings=cbreader.settings.base
+2 -1
View File
@@ -85,13 +85,14 @@ def clean_files(files: QuerySet, user: AbstractBaseUser, dir_path: Path, directo
for new_comic in file_list - files_db_set: for new_comic in file_list - files_db_set:
if new_comic.suffix.lower() in settings.SUPPORTED_FILES: if new_comic.suffix.lower() in settings.SUPPORTED_FILES:
new_book = models.ComicBook(file_name=new_comic.name, directory=directory) new_book = models.ComicBook(file_name=new_comic.name, directory=directory)
archive, archive_type = new_book.get_archive()
try: try:
archive, archive_type = new_book.get_archive()
if archive_type == 'archive': if archive_type == 'archive':
new_book.page_count = len(get_archive_files(archive)) new_book.page_count = len(get_archive_files(archive))
elif archive_type == 'pdf': elif archive_type == 'pdf':
new_book.page_count = archive.page_count new_book.page_count = archive.page_count
except NotCompatibleArchive: except NotCompatibleArchive:
# Unreadable/corrupt archive - index the file with no page count
pass pass
books_to_add.append(new_book) books_to_add.append(new_book)
models.ComicBook.objects.bulk_create(books_to_add) models.ComicBook.objects.bulk_create(books_to_add)