This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new d30b331 Move code to delete a file to the release writer
d30b331 is described below
commit d30b331d9e47778a0e6bb4c71f71b485e9d52c54
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Sep 11 19:55:18 2025 +0100
Move code to delete a file to the release writer
---
atr/routes/draft.py | 34 +++-------------------------------
atr/storage/writers/release.py | 29 +++++++++++++++++++++++++++++
atr/storage/writers/vote.py | 1 -
3 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/atr/routes/draft.py b/atr/routes/draft.py
index 4713830..1381f14 100644
--- a/atr/routes/draft.py
+++ b/atr/routes/draft.py
@@ -29,7 +29,6 @@ import aioshutil
import asfquart.base as base
import quart
-import atr.analysis as analysis
import atr.construct as construct
import atr.forms as forms
import atr.log as log
@@ -129,38 +128,11 @@ async def delete_file(session: routes.CommitterSession,
project_name: str, versi
return await session.redirect(compose.selected,
project_name=project_name, version_name=version_name)
rel_path_to_delete = pathlib.Path(str(form.file_path.data))
- metadata_files_deleted = 0
try:
- description = "File deletion through web interface"
- async with revision.create_and_manage(
- project_name, version_name, session.uid, description=description
- ) as creating:
- # Uses new_revision_number for logging only
- # Path to delete within the new revision directory
- path_in_new_revision = creating.interim_path / rel_path_to_delete
-
- # Check that the file exists in the new revision
- if not await aiofiles.os.path.exists(path_in_new_revision):
- # This indicates a potential severe issue with hard linking or
logic
- log.error(f"SEVERE ERROR! File {rel_path_to_delete} not found
in new revision before deletion")
- raise routes.FlashError("File to delete was not found in the
new revision")
-
- # Check whether the file is an artifact
- if analysis.is_artifact(path_in_new_revision):
- # If so, delete all associated metadata files in the new
revision
- async for p in
util.paths_recursive(path_in_new_revision.parent):
- # Construct full path within the new revision
- metadata_path_obj = creating.interim_path / p
- if p.name.startswith(rel_path_to_delete.name + "."):
- # TODO: Move to the storage interface
- await aiofiles.os.remove(metadata_path_obj)
- metadata_files_deleted += 1
-
- # Delete the file
- # TODO: Move to the storage interface
- await aiofiles.os.remove(path_in_new_revision)
-
+ async with storage.write(session.uid) as write:
+ wacp = await write.as_project_committee_member(project_name)
+ metadata_files_deleted = await
wacp.release.delete_file(project_name, version_name, rel_path_to_delete)
except Exception as e:
log.exception("Error deleting file:")
await quart.flash(f"Error deleting file: {e!s}", "error")
diff --git a/atr/storage/writers/release.py b/atr/storage/writers/release.py
index d9dd687..5c438ee 100644
--- a/atr/storage/writers/release.py
+++ b/atr/storage/writers/release.py
@@ -27,6 +27,7 @@ from typing import TYPE_CHECKING
import aiofiles.os
import aioshutil
+import atr.analysis as analysis
import atr.db as db
import atr.log as log
import atr.models.api as api
@@ -91,6 +92,34 @@ class CommitteeParticipant(FoundationCommitter):
) as _creating:
yield _creating
+ async def delete_file(self, project_name: str, version: str,
rel_path_to_delete: pathlib.Path) -> int:
+ metadata_files_deleted = 0
+ description = "File deletion through web interface"
+ async with self.create_and_manage_revision(project_name, version,
description) as creating:
+ # Uses new_revision_number for logging only
+ # Path to delete within the new revision directory
+ path_in_new_revision = creating.interim_path / rel_path_to_delete
+
+ # Check that the file exists in the new revision
+ if not await aiofiles.os.path.exists(path_in_new_revision):
+ # This indicates a potential severe issue with hard linking or
logic
+ log.error(f"SEVERE ERROR! File {rel_path_to_delete} not found
in new revision before deletion")
+ raise storage.AccessError("File to delete was not found in the
new revision")
+
+ # Check whether the file is an artifact
+ if analysis.is_artifact(path_in_new_revision):
+ # If so, delete all associated metadata files in the new
revision
+ async for p in
util.paths_recursive(path_in_new_revision.parent):
+ # Construct full path within the new revision
+ metadata_path_obj = creating.interim_path / p
+ if p.name.startswith(rel_path_to_delete.name + "."):
+ await aiofiles.os.remove(metadata_path_obj)
+ metadata_files_deleted += 1
+
+ # Delete the file
+ await aiofiles.os.remove(path_in_new_revision)
+ return metadata_files_deleted
+
async def import_from_svn(
self, project_name: str, version_name: str, svn_url: str, revision:
str, target_subdirectory: str | None
) -> sql.Task:
diff --git a/atr/storage/writers/vote.py b/atr/storage/writers/vote.py
index 424e876..419cf6d 100644
--- a/atr/storage/writers/vote.py
+++ b/atr/storage/writers/vote.py
@@ -105,7 +105,6 @@ class CommitteeParticipant(FoundationCommitter):
body_text = "\n\n".join(body)
in_reply_to = vote_thread_mid
- # TODO: Move this to the storage interface
task = sql.Task(
status=sql.TaskStatus.QUEUED,
task_type=sql.TaskType.MESSAGE_SEND,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]