Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload: Rename backend to delete_message_attachment_from_storage.

Alex Vandiver6c58b765129d
diff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.py
index 696de4b8e5e..d772ce65dd0 100644
--- a/zerver/lib/upload/__init__.py
+++ b/zerver/lib/upload/__init__.py
@@ -298,7 +298,7 @@ def save_attachment_contents(path_id: str, filehandle: IO[bytes]) -> None:
def delete_message_attachment(path_id: str, *, raw_path: bool = False) -> None:
- upload_backend.delete_message_attachment(path_id)
+ upload_backend.delete_message_attachment_from_storage(path_id)
@contextmanager
diff --git a/zerver/lib/upload/base.py b/zerver/lib/upload/base.py
index a499bf5c99f..0e776b400fc 100644
--- a/zerver/lib/upload/base.py
+++ b/zerver/lib/upload/base.py
@@ -48,7 +48,9 @@ class ZulipUploadBackend:
def attachment_source(self, path_id: str) -> StreamingSourceWithSize:
raise NotImplementedError
- def delete_message_attachment(self, path_id: str, *, raw_path: bool = False) -> None:
+ def delete_message_attachment_from_storage(
+ self, path_id: str, *, raw_path: bool = False
+ ) -> None:
"""This must delete the attachment, any adjacent .info files, and any thumbnails.
If raw_path is passed, just delete the one path provided.
@@ -66,7 +68,7 @@ class ZulipUploadBackend:
flush: None | Callable[[list[str]], None] = None,
) -> Iterator[Callable[[str], None]]:
def delete_one(path_id: str) -> None:
- self.delete_message_attachment(path_id, raw_path=raw_paths)
+ self.delete_message_attachment_from_storage(path_id, raw_path=raw_paths)
if flush:
flush([path_id])
diff --git a/zerver/lib/upload/local.py b/zerver/lib/upload/local.py
index a07dbb9236e..72db24d8035 100644
--- a/zerver/lib/upload/local.py
+++ b/zerver/lib/upload/local.py
@@ -118,7 +118,9 @@ class LocalUploadBackend(ZulipUploadBackend):
)
@override
- def delete_message_attachment(self, path_id: str, *, raw_path: bool = False) -> None:
+ def delete_message_attachment_from_storage(
+ self, path_id: str, *, raw_path: bool = False
+ ) -> None:
delete_local_file("files", path_id)
if not raw_path:
delete_local_file("files", f"{path_id}.info")
diff --git a/zerver/lib/upload/s3.py b/zerver/lib/upload/s3.py
index 96562a1a8c8..90d02b3214f 100644
--- a/zerver/lib/upload/s3.py
+++ b/zerver/lib/upload/s3.py
@@ -293,7 +293,9 @@ class S3UploadBackend(ZulipUploadBackend):
)
@override
- def delete_message_attachment(self, path_id: str, *, raw_path: bool = False) -> None:
+ def delete_message_attachment_from_storage(
+ self, path_id: str, *, raw_path: bool = False
+ ) -> None:
with self.delete_message_attachments(raw_paths=raw_path) as delete_one:
delete_one(path_id)
diff --git a/zerver/tests/test_upload_s3.py b/zerver/tests/test_upload_s3.py
index fceeda3cae5..fd8fa4a7f35 100644
--- a/zerver/tests/test_upload_s3.py
+++ b/zerver/tests/test_upload_s3.py
@@ -190,7 +190,9 @@ class S3Test(ZulipTestCase):
self.assertIsNotNone(bucket.Object(path_id).get())
path_ids.append(path_id)
- with patch.object(S3UploadBackend, "delete_message_attachment") as single_delete:
+ with patch.object(
+ S3UploadBackend, "delete_message_attachment_from_storage"
+ ) as single_delete:
with delete_message_attachments() as delete_one:
for path_id in path_ids:
delete_one(path_id)