From 9c0a046c573c2ba9a00c8b7364e38b06b5fa007e Mon Sep 17 00:00:00 2001 From: marwin Date: Sat, 4 Apr 2026 21:01:32 +0200 Subject: [PATCH] Fix ebook upload: new books appear at top, 50 MB limit frontend/backend - Create EBookProgress on upload so new books get a last_read timestamp and sort to the top of the book list - Update frontend file size check from 10 MB to 50 MB - Fix backend error message to say 50 MB instead of 10 MB Co-Authored-By: Claude Sonnet 4.6 --- books/views.py | 3 ++- static/js/app.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/books/views.py b/books/views.py index 4f6e1e3..fdad268 100644 --- a/books/views.py +++ b/books/views.py @@ -67,7 +67,7 @@ def upload_book(request): return JsonResponse({'error': 'invalid base64 in data_ct'}, status=400) if raw_size > max_bytes: - return JsonResponse({'error': 'file too large (max 10 MB)'}, status=400) + return JsonResponse({'error': 'file too large (max 50 MB)'}, status=400) book = EBook.objects.create( user=request.user, @@ -76,6 +76,7 @@ def upload_book(request): data_ct=data_ct, data_iv=data_iv, ) + EBookProgress.objects.create(user=request.user, book=book) return JsonResponse({'ok': True, 'id': book.id}) diff --git a/static/js/app.js b/static/js/app.js index 438a675..d0fb3c8 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -2884,8 +2884,8 @@ async function uploadEbook(file) { if (statusEl) statusEl.textContent = 'Only .epub and .pdf files are supported.'; return; } - if (file.size > 10 * 1024 * 1024) { - if (statusEl) statusEl.textContent = 'File too large (max 10 MB).'; + if (file.size > 50 * 1024 * 1024) { + if (statusEl) statusEl.textContent = 'File too large (max 50 MB).'; return; }