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-atr-experiments.git


The following commit(s) were added to refs/heads/main by this push:
     new 8c3fe7b  Add a file size field for artifacts
8c3fe7b is described below

commit 8c3fe7b50dcb600a729db21eb6c12542c48f1b9e
Author: Sean B. Palmer <s...@miscoranda.com>
AuthorDate: Wed Feb 19 20:25:48 2025 +0200

    Add a file size field for artifacts
---
 atr/db/models.py                                            |  2 ++
 atr/routes.py                                               | 13 ++++++++-----
 atr/templates/candidate-review.html                         |  4 ++++
 docs/plan.md                                                | 11 +++++------
 ...f38_initial_schema.py => b8dd95b83501_initial_schema.py} |  6 +++---
 5 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/atr/db/models.py b/atr/db/models.py
index 6b801b1..aa0e58b 100644
--- a/atr/db/models.py
+++ b/atr/db/models.py
@@ -145,6 +145,8 @@ class Package(SQLModel, table=True):
     signature_sha3: str
     # Uploaded timestamp
     uploaded: datetime.datetime
+    # The size of the file in bytes
+    bytes_size: int
 
     # Many-to-one: A package belongs to one release
     release_key: str | None = Field(default=None, 
foreign_key="release.storage_key")
diff --git a/atr/routes.py b/atr/routes.py
index 55127ae..ad60c3e 100644
--- a/atr/routes.py
+++ b/atr/routes.py
@@ -125,8 +125,8 @@ async def release_attach_post(session: ClientSession, 
request: Request) -> Respo
 
     # Save files using their hashes as filenames
     uploads_path = Path(get_release_storage_dir())
-    artifact_sha3 = await save_file_by_hash(uploads_path, artifact_file)
-    signature_sha3 = await save_file_by_hash(uploads_path, signature_file)
+    artifact_sha3, artifact_size = await save_file_by_hash(uploads_path, 
artifact_file)
+    signature_sha3, _ = await save_file_by_hash(uploads_path, signature_file)
 
     # Check if these files are already attached to this release
     async with get_session() as db_session:
@@ -158,6 +158,7 @@ async def release_attach_post(session: ClientSession, 
request: Request) -> Respo
                 sha512=sha512,
                 release_key=release_key,
                 uploaded=datetime.datetime.now(datetime.UTC),
+                bytes_size=artifact_size,
             )
             db_session.add(package)
 
@@ -568,12 +569,13 @@ async def root_candidate_review() -> str:
         return await render_template("candidate-review.html", 
releases=user_releases)
 
 
-async def save_file_by_hash(base_dir: Path, file: FileStorage) -> str:
+async def save_file_by_hash(base_dir: Path, file: FileStorage) -> tuple[str, 
int]:
     """
     Save a file using its SHA3-256 hash as the filename.
-    Returns the path where the file was saved and its hash.
+    Returns the hash and size in bytes of the saved file.
     """
     sha3 = hashlib.sha3_256()
+    total_bytes = 0
 
     # Create temporary file to stream to while computing hash
     temp_path = base_dir / f"temp-{secrets.token_hex(8)}"
@@ -586,6 +588,7 @@ async def save_file_by_hash(base_dir: Path, file: 
FileStorage) -> str:
                 if not chunk:
                     break
                 sha3.update(chunk)
+                total_bytes += len(chunk)
                 await f.write(chunk)
 
         file_hash = sha3.hexdigest()
@@ -599,7 +602,7 @@ async def save_file_by_hash(base_dir: Path, file: 
FileStorage) -> str:
             # If file already exists, just remove the temp file
             await aiofiles.os.remove(temp_path)
 
-        return file_hash
+        return file_hash, total_bytes
     except Exception as e:
         if await aiofiles.os.path.exists(temp_path):
             await aiofiles.os.remove(temp_path)
diff --git a/atr/templates/candidate-review.html 
b/atr/templates/candidate-review.html
index 3f61da2..983d244 100644
--- a/atr/templates/candidate-review.html
+++ b/atr/templates/candidate-review.html
@@ -133,6 +133,10 @@
             <th>Artifact Hash (SHA-512)</th>
             <td>{{ package.sha512 }}</td>
           </tr>
+          <tr>
+            <th>File Size</th>
+            <td>{{ package.bytes_size }} bytes</td>
+          </tr>
           <tr>
             <th>Signature Hash (SHA3-256)</th>
             <td>{{ package.signature_sha3 }}</td>
diff --git a/docs/plan.md b/docs/plan.md
index 85ecb60..da04d74 100644
--- a/docs/plan.md
+++ b/docs/plan.md
@@ -5,16 +5,15 @@ This is a rough plan of immediate tasks. The priority of 
these tasks may change,
 ## UX improvements
 
 1. Enhance RC display
-   - Add the option to upload package artifacts without signatures
-   - Replace raw file hashes with the original filenames in the UI
-   - Add file size and upload timestamp
-   - Improve the layout of file listings
+   - [DONE] Augment raw file hashes with the original filenames in the UI
+   - [DONE] Add file size and upload timestamp
+   - [DONE] Improve the layout of file listings
+   - Potentially add the option to upload package artifacts without signatures
    - Show validation status indicators
 
 2. Improve key management interface
+   - [DONE] Display which PMCs are using each key
    - Add key expiration warnings
-   - Display which PMCs are using each key
-   - Improve key selection during RC creation
 
 3. Release status dashboard
    - Add progress indicators for release phases
diff --git a/migrations/versions/1779875a3f38_initial_schema.py 
b/migrations/versions/b8dd95b83501_initial_schema.py
similarity index 84%
rename from migrations/versions/1779875a3f38_initial_schema.py
rename to migrations/versions/b8dd95b83501_initial_schema.py
index 0210d4c..bc0deed 100644
--- a/migrations/versions/1779875a3f38_initial_schema.py
+++ b/migrations/versions/b8dd95b83501_initial_schema.py
@@ -1,15 +1,15 @@
 """initial_schema
 
-Revision ID: 1779875a3f38
+Revision ID: b8dd95b83501
 Revises:
-Create Date: 2025-02-19 19:55:33.587351
+Create Date: 2025-02-19 20:20:11.349128
 
 """
 
 from collections.abc import Sequence
 
 # revision identifiers, used by Alembic.
-revision: str = "1779875a3f38"
+revision: str = "b8dd95b83501"
 down_revision: str | None = None
 branch_labels: str | Sequence[str] | None = None
 depends_on: str | Sequence[str] | None = None


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tooling.apache.org
For additional commands, e-mail: dev-h...@tooling.apache.org

Reply via email to