From 89027ef16e1bb88cc209837871816bde9972fed3 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Wed, 23 Jul 2025 20:10:29 -0700 Subject: [PATCH] quickfix: delete seedfile after the workflow has been deleted (#2763) Since seedfile deletion checks that the seedfile is not used in any workflow, it should be deleted after the workflow is removed. noticed in checking #2744 --- backend/btrixcloud/crawlconfigs.py | 16 ++++++++-------- backend/test/test_stop_cancel_crawl.py | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/btrixcloud/crawlconfigs.py b/backend/btrixcloud/crawlconfigs.py index 5f6ab73d..74dd7aae 100644 --- a/backend/btrixcloud/crawlconfigs.py +++ b/backend/btrixcloud/crawlconfigs.py @@ -976,14 +976,6 @@ class CrawlConfigOps: # if no crawls have been run, actually delete if not crawlconfig.crawlAttemptCount: - if crawlconfig.config and crawlconfig.config.seedFileId: - try: - await self.file_ops.delete_seed_file( - crawlconfig.config.seedFileId, org - ) - except HTTPException: - pass - result = await self.crawl_configs.delete_one( {"_id": crawlconfig.id, "oid": crawlconfig.oid} ) @@ -991,6 +983,14 @@ class CrawlConfigOps: if result.deleted_count != 1: raise HTTPException(status_code=404, detail="failed_to_delete") + if crawlconfig and crawlconfig.config.seedFileId: + try: + await self.file_ops.delete_seed_file( + crawlconfig.config.seedFileId, org + ) + except HTTPException: + pass + status = "deleted" else: diff --git a/backend/test/test_stop_cancel_crawl.py b/backend/test/test_stop_cancel_crawl.py index b82f718b..0d75aac1 100644 --- a/backend/test/test_stop_cancel_crawl.py +++ b/backend/test/test_stop_cancel_crawl.py @@ -181,7 +181,11 @@ def test_stop_crawl_partial( def test_crawl_with_hostname(default_org_id, crawler_auth_headers): r = requests.get( f"{API_PREFIX}/orgs/{default_org_id}/crawls/{crawl_id}/replay.json", - headers={"X-Forwarded-Proto": "https", "host": "custom-domain.example.com", **crawler_auth_headers}, + headers={ + "X-Forwarded-Proto": "https", + "host": "custom-domain.example.com", + **crawler_auth_headers, + }, ) assert r.status_code == 200 assert r.json()["pagesQueryUrl"].startswith("https://custom-domain.example.com/")