diff --git a/backend/btrixcloud/basecrawls.py b/backend/btrixcloud/basecrawls.py index d94717786d..2cf09a0f85 100644 --- a/backend/btrixcloud/basecrawls.py +++ b/backend/btrixcloud/basecrawls.py @@ -426,11 +426,21 @@ async def _delete_crawl_files( return size - async def delete_crawl_files(self, crawl_id: str, oid: UUID): - """Delete crawl files""" + async def delete_failed_crawl_files(self, crawl_id: str, oid: UUID): + """Delete crawl files for failed crawl""" crawl = await self.get_base_crawl(crawl_id) org = await self.orgs.get_org_by_id(oid) - return await self._delete_crawl_files(crawl, org) + await self._delete_crawl_files(crawl, org) + await self.crawls.find_one_and_update( + {"_id": crawl_id, "oid": oid}, + { + "$set": { + "files": [], + "fileCount": 0, + "fileSize": 0, + } + }, + ) async def delete_all_crawl_qa_files(self, crawl_id: str, org: Organization): """Delete files for all qa runs in a crawl""" diff --git a/backend/btrixcloud/operator/crawls.py b/backend/btrixcloud/operator/crawls.py index c7f9861ee6..01d81ca407 100644 --- a/backend/btrixcloud/operator/crawls.py +++ b/backend/btrixcloud/operator/crawls.py @@ -1707,7 +1707,7 @@ async def do_crawl_finished_tasks( ) if state in FAILED_STATES: - await self.crawl_ops.delete_crawl_files(crawl.id, crawl.oid) + await self.crawl_ops.delete_failed_crawl_files(crawl.id, crawl.oid) await self.page_ops.delete_crawl_pages(crawl.id, crawl.oid) await self.event_webhook_ops.create_crawl_finished_notification(