diff --git a/app/smb_processor.py b/app/smb_processor.py index 323603a..9352d2a 100644 --- a/app/smb_processor.py +++ b/app/smb_processor.py @@ -66,8 +66,14 @@ def _list_pdf_files(source_path: str) -> list[str]: def _read_smb_file(filepath: str) -> bytes: - """Read a file from SMB share into memory.""" - with smbclient.open_file(filepath, mode="rb") as f: + """Read a file from SMB share into memory. + + share_access="rwd" allows concurrent read/write/delete operations on the same + file, which is required because smbclient keeps the underlying SMB connection + in a pool. Without this, subsequent rename/delete on the file fails with + STATUS_ACCESS_DENIED until the session is closed. + """ + with smbclient.open_file(filepath, mode="rb", share_access="rwd") as f: return f.read()