diff --git a/cps/helper.py b/cps/helper.py index 9871af0c..dce1a280 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -747,9 +747,10 @@ def get_book_cover(book_id, resolution=None): return get_book_cover_internal(book, use_generic_cover_on_failure=True, resolution=resolution) -# Called only by kobo sync -> cover not found should be answered with 404 and not with default cover -def get_book_cover_with_uuid(book_uuid, resolution=None): +def get_book_cover_with_uuid(book_uuid, resolution=None, none_on_missing=False): book = calibre_db.get_book_by_uuid(book_uuid) + if not book and none_on_missing: + return # allows kobo.HandleCoverImageRequest to proxy request return get_book_cover_internal(book, use_generic_cover_on_failure=False, resolution=resolution) diff --git a/cps/kobo.py b/cps/kobo.py index de5d3235..8afadafd 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -930,7 +930,10 @@ def get_current_bookmark_response(current_bookmark): @kobo.route("//////image.jpg") @requires_kobo_auth def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale): - book_cover = helper.get_book_cover_with_uuid(book_uuid, resolution=COVER_THUMBNAIL_SMALL) + book_cover = helper.get_book_cover_with_uuid( + book_uuid, + resolution=COVER_THUMBNAIL_SMALL, + none_on_missing=config.config_kobo_proxy) if not book_cover: if config.config_kobo_proxy: log.debug("Cover for unknown book: %s proxied to kobo" % book_uuid) @@ -941,7 +944,7 @@ def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale): else: log.debug("Cover for unknown book: %s requested" % book_uuid) # additional proxy request make no sense, -> direct return - return make_response(jsonify({})) + return abort(404) log.debug("Cover request received for book %s" % book_uuid) return book_cover