We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8ace65 commit e9af63aCopy full SHA for e9af63a
1 file changed
openlibrary/plugins/upstream/borrow.py
@@ -1,5 +1,6 @@
1
"""Handlers for borrowing books"""
2
3
+import contextlib
4
import copy
5
import hashlib
6
import hmac
@@ -192,11 +193,9 @@ def POST(self, key): # noqa: PLR0915
192
193
raise web.seeother(redirect_url)
194
195
if action == 'return':
- try:
196
+ # Try to return the loan, catching PatronAccessException explicitly so we can verify if the loan is actually gone.
197
+ with contextlib.suppress(lending.PatronAccessException):
198
lending.s3_loan_api(s3_keys, ocaid=edition.ocaid, action='return_loan')
- except lending.PatronAccessException:
- # Loan may have already expired — check status before claiming success
199
- pass
200
stats.increment('ol.loans.return')
201
edition.update_loan_status()
202
user.update_loan_status()
0 commit comments