diff --git a/actions/azurestorage.js b/actions/azurestorage.js index b2b89887..48b8e66d 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -84,6 +84,31 @@ const buildGetBlobListQueryPath = ({ containerName, casefolderID }) => { ); }; +const buildHashMetadataPaths = ({ containerName, casefolderID, blobname }) => { + return { + "hashedfilepath": hashAPIPath( + buildDownloadBlobQueryPath({ + containerName, + casefolderID, + blobname + }) + ), + "hasheddeletepath": hashAPIPath( + buildDeleteBlobQueryPath({ + containerName, + casefolderID, + blobname + }) + ), + "hashgetblobs": hashAPIPath( + buildGetBlobListQueryPath({ + containerName, + casefolderID + }) + ) + }; +}; + export const createContainerSas = async (containerName) => { // Get environment variables @@ -266,33 +291,18 @@ export const getBlobs = async (containerName, casefolderID) => { encodeURIComponent(casefolderID) + "&blobname=" + encodeURIComponent(blob.name), - "hashedfilepath": hashAPIPath( - buildDownloadBlobQueryPath({ - containerName, - casefolderID, - blobname: blob.name.split("/")[2] - }) - ), + ...buildHashMetadataPaths({ + containerName, + casefolderID, + blobname: blob.name.split("/")[2] + }), "deletepath": "/api/file/deleteblob?container=" + containerName + "&casefolderID=" + encodeURIComponent(casefolderID) + "&blobname=" + - encodeURIComponent(blob.name.split("/")[2]), - "hasheddeletepath": hashAPIPath( - buildDeleteBlobQueryPath({ - containerName, - casefolderID, - blobname: blob.name.split("/")[2] - }) - ), - "hashgetblobs": hashAPIPath( - buildGetBlobListQueryPath({ - containerName, - casefolderID - }) - ) + encodeURIComponent(blob.name.split("/")[2]) }); } //console.log("blobObj:", blobObj); @@ -1296,26 +1306,11 @@ export const getProgressBlobs = async (containerName, caseReference) => { "contentLength": blob.properties.contentLength, "contentType": blob.contentType, "lastModified": blob.properties.lastModified, - "hashedfilepath": hashAPIPath( - buildDownloadBlobQueryPath({ - containerName, - casefolderID: caseReference, - blobname: blob.name.split("/")[1] - }) - ), - "hasheddeletepath": hashAPIPath( - buildDeleteBlobQueryPath({ - containerName, - casefolderID: caseReference, - blobname: blob.name.split("/")[1] - }) - ), - "hashgetblobs": hashAPIPath( - buildGetBlobListQueryPath({ - containerName, - casefolderID: caseReference - }) - ) + ...buildHashMetadataPaths({ + containerName, + casefolderID: caseReference, + blobname: blob.name.split("/")[1] + }) }); } @@ -1503,14 +1498,12 @@ export const getRepsFilesBlobs = async ( ) + "&blobname=" + encodeURIComponent(blob.name.split("/")[3]), - "hashedfilepath": hashAPIPath( - buildDownloadBlobQueryPath({ - containerName, - casefolderID: - blob.name.split("/")[0] + "/" + blob.name.split("/")[1], - blobname: blob.name.split("/")[3] - }) - ), + ...buildHashMetadataPaths({ + containerName, + casefolderID: + blob.name.split("/")[0] + "/" + blob.name.split("/")[1], + blobname: blob.name.split("/")[3] + }), "deletepath": "/api/file/deleteblob?container=" + containerName + @@ -1519,22 +1512,7 @@ export const getRepsFilesBlobs = async ( "/" + blob.name.split("/")[1] + "&blobname=" + - blob.name.split("/")[3], - "hasheddeletepath": hashAPIPath( - buildDeleteBlobQueryPath({ - containerName, - casefolderID: - blob.name.split("/")[0] + "/" + blob.name.split("/")[1], - blobname: blob.name.split("/")[3] - }) - ), - "hashgetblobs": hashAPIPath( - buildGetBlobListQueryPath({ - containerName, - casefolderID: - blob.name.split("/")[0] + "/" + blob.name.split("/")[1] - }) - ) + blob.name.split("/")[3] }); } console.log("blobObj:", blobObj); diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index 7f54c220..f9e737d4 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -2942,3 +2942,36 @@ Validation: Follow-ups: - Remaining potential cleanups in `actions/azurestorage.js` are broader non-slice refactors (legacy logging verbosity, large function decomposition) and should be handled separately to keep risk bounded. + +--- + +### CL-082: TASK22269 Slice B1.7 — azurestorage hash metadata helper consolidation + +date: 2026-03-25 +author: Cline +scope: `actions/azurestorage.js` +type: change +rationale: Continue bounded normalization by consolidating repeated hash metadata object field population into a single local helper. +impact: Reduces duplicated metadata field assembly and drift risk while preserving existing output shape and hash behavior. +status: completed + +Summary: + +- Added `buildHashMetadataPaths({ containerName, casefolderID, blobname })` helper. +- Replaced repeated per-object hash metadata assignment in: + - `getBlobs` + - `getProgressBlobs` + - `getRepsFilesBlobs` +- Preserved existing metadata contracts: + - keys unchanged: `hashedfilepath`, `hasheddeletepath`, `hashgetblobs` + - same encoded query path inputs and route semantics. + +Validation: + +- `npm run lint` -> pass with warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors) +- `node tests/phase22/index.test.cjs` -> pass +- `node tests/phase7/service-behaviour.test.cjs` -> pass (13/13) + +Follow-ups: + +- Any further `azurestorage.js` cleanup should remain bounded (e.g., logging-only normalization) and separated from behavior-affecting refactors.