diff --git a/actions/azurestorage.js b/actions/azurestorage.js index 48b8e66d..3cc4f2d2 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -267,16 +267,16 @@ export const getBlobs = async (containerName, casefolderID) => { for await (const blob of containerClient.listBlobsFlat({ prefix: casefolderID + "/files/" })) { + const blobPathParts = blob.name.split("/"); + const fileName = blobPathParts[2]; let blobDocumentType = blob.name .split("/")[2] .slice(0, blob.name.split("/")[2].indexOf("_")); blobObj.push({ - "name": blob.name.split("/")[2], + "name": fileName, "path": blob.name, - "documentType": getDocumentTypeFromFilename( - blob.name.split("/")[2] - ), + "documentType": getDocumentTypeFromFilename(fileName), "versionId": blob.versionId, "caseObj": casefolderID + "/" + casefolderID + "_case.json", "isCurrentVersion": blob.isCurrentVersion, @@ -294,7 +294,7 @@ export const getBlobs = async (containerName, casefolderID) => { ...buildHashMetadataPaths({ containerName, casefolderID, - blobname: blob.name.split("/")[2] + blobname: fileName }), "deletepath": "/api/file/deleteblob?container=" + @@ -302,7 +302,7 @@ export const getBlobs = async (containerName, casefolderID) => { "&casefolderID=" + encodeURIComponent(casefolderID) + "&blobname=" + - encodeURIComponent(blob.name.split("/")[2]) + encodeURIComponent(fileName) }); } //console.log("blobObj:", blobObj); @@ -1296,9 +1296,12 @@ export const getProgressBlobs = async (containerName, caseReference) => { for await (const blob of containerClient.listBlobsFlat({ prefix: caseReference + "/" + caseReference + "_appeal.json" })) { - console.log("getProgressBlobs in here", blob.name.split("/")); + const blobPathParts = blob.name.split("/"); + const appealBlobName = blobPathParts[1]; + + console.log("getProgressBlobs in here", blobPathParts); blobObj.push({ - "name": blob.name.split("/")[1], + "name": appealBlobName, "path": blob.name, "versionId": blob.versionId, "caseObj": caseReference + "/" + caseReference + "_case.json", @@ -1309,7 +1312,7 @@ export const getProgressBlobs = async (containerName, caseReference) => { ...buildHashMetadataPaths({ containerName, casefolderID: caseReference, - blobname: blob.name.split("/")[1] + blobname: appealBlobName }) }); } @@ -1473,6 +1476,9 @@ export const getRepsFilesBlobs = async ( for await (const blob of containerClient.listBlobsFlat({ prefix: casefolderID + "/" + filenamePrefix + "/files/" })) { + const blobPathParts = blob.name.split("/"); + const casefolderPath = blobPathParts[0] + "/" + blobPathParts[1]; + const repFileName = blobPathParts[3]; let blobDocumentType = blob.name .split("/")[2] .slice(0, blob.name.split("/")[2].indexOf("_")); @@ -1480,11 +1486,9 @@ export const getRepsFilesBlobs = async ( console.log(blob.name); blobObj.push({ - "name": blob.name.split("/")[3], + "name": repFileName, "path": blob.name, - "documentType": getDocumentTypeFromFilename( - blob.name.split("/")[3] - ), + "documentType": getDocumentTypeFromFilename(repFileName), "versionId": blob.versionId, "isCurrentVersion": blob.isCurrentVersion, "contentLength": blob.properties.contentLength, @@ -1493,26 +1497,21 @@ export const getRepsFilesBlobs = async ( "/api/file/downloadblob?container=" + containerName + "&casefolderID=" + - encodeURIComponent( - blob.name.split("/")[0] + "/" + blob.name.split("/")[1] - ) + + encodeURIComponent(casefolderPath) + "&blobname=" + - encodeURIComponent(blob.name.split("/")[3]), + encodeURIComponent(repFileName), ...buildHashMetadataPaths({ containerName, - casefolderID: - blob.name.split("/")[0] + "/" + blob.name.split("/")[1], - blobname: blob.name.split("/")[3] + casefolderID: casefolderPath, + blobname: repFileName }), "deletepath": "/api/file/deleteblob?container=" + containerName + "&casefolderID=" + - blob.name.split("/")[0] + - "/" + - blob.name.split("/")[1] + + casefolderPath + "&blobname=" + - blob.name.split("/")[3] + repFileName }); } console.log("blobObj:", blobObj); diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index 15b9892a..d804bdab 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -3007,3 +3007,34 @@ Validation: Follow-ups: - Optional next bounded slice: add an explicit assertion for encoded `casefolderID` variants containing reserved query characters (`?`, `&`) if those inputs are expected in future flows. + +--- + +### CL-084: TASK22269 Slice B1.9 — azurestorage local split-value tidy in touched helper consumers + +date: 2026-03-26 +author: Cline +scope: `actions/azurestorage.js` +type: change +rationale: Execute the selected next bounded readability-only slice by reducing repeated `blob.name.split("/")` access in the recently touched helper-consumer functions. +impact: Non-behavioral maintainability improvement in azurestorage helper-consumer paths; no API/route contract changes. +status: completed + +Summary: + +- In targeted functions (`getBlobs`, `getProgressBlobs`, `getRepsFilesBlobs`), introduced local path-part variables to avoid repeated inline splitting: + - `blobPathParts` + - `fileName` / `appealBlobName` / `repFileName` + - `casefolderPath` +- Replaced repeated field reads and helper arguments with these locals in object construction and hash metadata composition. +- Preserved existing query composition and output shape/keys (including hashed path metadata fields). + +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: + +- Optional next bounded slice: logging-only normalization in these same azurestorage functions (no behavior change), done separately from structural refactors.