This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/sbp by this push:
new aee82146 Remove the unused field to rename a file when uploading
aee82146 is described below
commit aee82146153968c091a90714ef8de2fa2f7232ee
Author: Sean B. Palmer <[email protected]>
AuthorDate: Wed Mar 11 18:30:07 2026 +0000
Remove the unused field to rename a file when uploading
---
atr/post/upload.py | 3 +--
atr/shared/upload.py | 20 --------------------
atr/storage/writers/release.py | 25 +++++++------------------
3 files changed, 8 insertions(+), 40 deletions(-)
diff --git a/atr/post/upload.py b/atr/post/upload.py
index 930eda14..5b82a17b 100644
--- a/atr/post/upload.py
+++ b/atr/post/upload.py
@@ -194,13 +194,12 @@ async def _add_files(
version_name: safe.VersionName,
) -> web.WerkzeugResponse:
try:
- file_name = add_form.file_name
file_data = add_form.file_data
async with storage.write(session) as write:
wacp = await write.as_project_committee_participant(project_name)
creation_error, number_of_files, was_quarantined = await
wacp.release.upload_files(
- project_name, version_name, file_name, file_data
+ project_name, version_name, file_data
)
if creation_error is not None:
diff --git a/atr/shared/upload.py b/atr/shared/upload.py
index 033c97f6..dc24892a 100644
--- a/atr/shared/upload.py
+++ b/atr/shared/upload.py
@@ -18,8 +18,6 @@
import enum
from typing import Annotated, Literal
-import pydantic
-
import atr.form as form
type ADD_FILES = Literal["add_files"]
@@ -34,24 +32,6 @@ class SvnArea(enum.Enum):
class AddFilesForm(form.Form):
variant: ADD_FILES = form.value(ADD_FILES)
file_data: form.FileList = form.label("Files", "Select the files to
upload.")
- file_name: form.Filename = form.label(
- "File name",
- "Optional: Enter a file name to use when saving the file in the
release candidate. "
- "Only available when uploading a single file.",
- )
-
- @pydantic.field_validator("file_name", mode="after")
- @classmethod
- def validate_file_name_with_files(cls, value: form.Filename, info:
pydantic.ValidationInfo) -> form.Filename:
- # We can only get file_data if it comes before this field
- # TODO: Figure out how to use a model validator but associate an error
with a field
- # https://github.com/pydantic/pydantic/issues/8092
- # https://github.com/pydantic/pydantic/issues/9686
- # https://github.com/pydantic/pydantic-core/pull/1413
- file_data = info.data.get("file_data") or []
- if value and (len(file_data) != 1):
- raise ValueError("Filename can only be used when uploading a
single file")
- return value
class SvnImportForm(form.Form):
diff --git a/atr/storage/writers/release.py b/atr/storage/writers/release.py
index 443dd8e0..32394e4b 100644
--- a/atr/storage/writers/release.py
+++ b/atr/storage/writers/release.py
@@ -505,7 +505,6 @@ class CommitteeParticipant(FoundationCommitter):
self,
project_name: safe.ProjectName,
version_name: safe.VersionName,
- file_name: pathlib.Path | None,
files: Sequence[datastructures.FileStorage],
) -> tuple[str | None, int, bool]:
"""Process and save the uploaded files into a new draft revision."""
@@ -513,24 +512,14 @@ class CommitteeParticipant(FoundationCommitter):
description = f"Upload of {util.plural(number_of_files, 'file')}
through web interface"
async def modify(path: pathlib.Path, _old_rev: sql.Revision | None) ->
None:
- # Save each uploaded file to the new revision directory
for file in files:
- # Determine the target path within the new revision directory
- relative_file_path: pathlib.Path
- if not file_name:
- if not file.filename:
- raise storage.AccessError("No filename provided")
- # Validate the filename from multipart upload
- validated_path = form.to_relpath(file.filename)
- if validated_path is None:
- raise storage.AccessError("Invalid filename")
- relative_file_path = validated_path
- else:
- relative_file_path = file_name
-
- # Construct path inside the new revision directory
- target_path = path / relative_file_path
- # Ensure parent directories exist within the new revision
+ if not file.filename:
+ raise storage.AccessError("No filename provided")
+ # Validate the filename from multipart upload
+ validated_path = form.to_relpath(file.filename)
+ if validated_path is None:
+ raise storage.AccessError("Invalid filename")
+ target_path = path / validated_path
await aiofiles.os.makedirs(target_path.parent, exist_ok=True)
await self.__save_file(file, target_path)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]