Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RemoteFile): Don't try to delete unavailable S3 file #2259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion press/press/doctype/remote_file/remote_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

Check failure on line 1 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (UP009)

press/press/doctype/remote_file/remote_file.py:1:1: UP009 UTF-8 encoding declaration is unnecessary
# Copyright (c) 2020, Frappe and contributors
# For license information, please see license.txt

Expand Down Expand Up @@ -128,7 +128,7 @@
"""Delete specified objects identified by keys in the backups bucket."""
remote_files = list(set([x for x in remote_files if x]))
if not remote_files:
return

Check failure on line 131 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (RET502)

press/press/doctype/remote_file/remote_file.py:131:3: RET502 Do not implicitly `return None` in function able to return non-`None` value

buckets = {bucket: [] for bucket in frappe.get_all("Backup Bucket", pluck="name")}
buckets.update({frappe.db.get_single_value("Press Settings", "aws_s3_bucket"): []})
Expand Down Expand Up @@ -159,14 +159,14 @@
if TYPE_CHECKING:
from frappe.types import DF

bucket: DF.Data | None

Check failure on line 162 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:162:11: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
file_name: DF.Data | None

Check failure on line 163 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:163:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
file_path: DF.Text | None

Check failure on line 164 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:164:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
file_size: DF.Data | None

Check failure on line 165 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:165:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
file_type: DF.Data | None

Check failure on line 166 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:166:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
site: DF.Link | None

Check failure on line 167 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:167:9: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
status: DF.Literal["Available", "Unavailable"]
url: DF.Code | None

Check failure on line 169 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (FA102)

press/press/doctype/remote_file/remote_file.py:169:8: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
# end: auto-generated types

@property
Expand All @@ -174,7 +174,7 @@
if not self.bucket:
return None

elif self.bucket == frappe.db.get_single_value(

Check failure on line 177 in press/press/doctype/remote_file/remote_file.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (RET505)

press/press/doctype/remote_file/remote_file.py:177:3: RET505 Unnecessary `elif` after `return` statement
"Press Settings", "remote_uploads_bucket"
):
access_key_id = frappe.db.get_single_value("Press Settings", "remote_access_key_id")
Expand Down Expand Up @@ -231,7 +231,8 @@
)

def on_trash(self):
self.delete_remote_object()
if self.status != "Unavailable":
self.delete_remote_object()

Check warning on line 235 in press/press/doctype/remote_file/remote_file.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/remote_file/remote_file.py#L234-L235

Added lines #L234 - L235 were not covered by tests

@frappe.whitelist()
def get_download_link(self):
Expand Down
Loading