Preserve SharePoint distribution when the site-note save fails loudly 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-14 13:50:31 +00:00
parent e31d2ad2d1
commit 38cae15f4d

View file

@ -119,6 +119,7 @@ class PashubService:
job_id, include_other=request.get_other_files
)
upload_records: List[_FileUploadRecord] = []
if uprn or hubspot_deal_id:
logger.info("Uploading files to s3")
file_source = (
@ -129,7 +130,6 @@ class PashubService:
upload_records = self._upload_to_s3_and_update_db(
downloaded.core, uprn, hubspot_deal_id, file_source
)
self._save_site_notes(upload_records, active_client, job_id)
if downloaded.other:
self._upload_to_s3_and_update_db(
@ -153,6 +153,11 @@ class PashubService:
property_folder_path = f"{request.sharepoint_link}/{match}"
self._upload_to_sharepoint(property_folder_path, downloaded.core + downloaded.other)
# Ordered after S3 + SharePoint so a loud RdSAP Summary failure cannot
# cost us file distribution: the Property refuses to persist with an
# incomplete Lodged Performance, but the evidence is already delivered.
self._save_site_notes(upload_records, active_client, job_id)
for df in downloaded.core + downloaded.other:
try:
os.remove(df.file_path)