Skip to content

Commit 8f061e4

Browse files
fix(exports): change the way to remove the local export files after s3 upload (#7224)
Co-authored-by: Adrián Jesús Peña Rodríguez <[email protected]>
1 parent 3fb86d7 commit 8f061e4

File tree

7 files changed

+59
-285
lines changed

7 files changed

+59
-285
lines changed

api/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to the **Prowler API** are documented in this file.
44

55
---
66

7+
## [v1.5.1] (Prowler v5.4.1)
8+
9+
### Fixed
10+
- Fixed a race condition when deleting export files after the S3 upload [(#7172)](https://github.com/prowler-cloud/prowler/pull/7172).
11+
12+
---
13+
714
## [v1.5.0] (Prowler v5.4.0)
815

916
### Added

api/poetry.lock

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Prowler's API (Django/DRF)"
88
license = "Apache-2.0"
99
name = "prowler-api"
1010
package-mode = false
11-
version = "1.5.0"
11+
version = "1.5.1"
1212

1313
[tool.poetry.dependencies]
1414
celery = {extras = ["pytest"], version = "^5.4.0"}

api/src/backend/api/specs/v1.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: 3.0.3
22
info:
33
title: Prowler API
4-
version: 1.5.0
4+
version: 1.5.1
55
description: |-
66
Prowler API specification.
77

api/src/backend/api/v1/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class SchemaView(SpectacularAPIView):
239239

240240
def get(self, request, *args, **kwargs):
241241
spectacular_settings.TITLE = "Prowler API"
242-
spectacular_settings.VERSION = "1.5.0"
242+
spectacular_settings.VERSION = "1.5.1"
243243
spectacular_settings.DESCRIPTION = (
244244
"Prowler API specification.\n\nThis file is auto-generated."
245245
)

api/src/backend/tasks/tasks.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pathlib import Path
12
from shutil import rmtree
23

34
from celery import chain, shared_task
@@ -264,10 +265,14 @@ def generate_outputs(scan_id: str, provider_id: str, tenant_id: str):
264265
uploaded = _upload_to_s3(tenant_id, output_directory, scan_id)
265266

266267
if uploaded:
268+
# Remove the local files after upload
269+
try:
270+
rmtree(Path(output_directory).parent, ignore_errors=True)
271+
except FileNotFoundError as e:
272+
logger.error(f"Error deleting output files: {e}")
273+
267274
output_directory = uploaded
268275
uploaded = True
269-
# Remove the local files after upload
270-
rmtree(DJANGO_TMP_OUTPUT_DIRECTORY, ignore_errors=True)
271276
else:
272277
uploaded = False
273278

0 commit comments

Comments
 (0)