TASK22269: tidy azurestorage blob path split locals
This commit is contained in:
+23
-24
@@ -267,16 +267,16 @@ export const getBlobs = async (containerName, casefolderID) => {
|
|||||||
for await (const blob of containerClient.listBlobsFlat({
|
for await (const blob of containerClient.listBlobsFlat({
|
||||||
prefix: casefolderID + "/files/"
|
prefix: casefolderID + "/files/"
|
||||||
})) {
|
})) {
|
||||||
|
const blobPathParts = blob.name.split("/");
|
||||||
|
const fileName = blobPathParts[2];
|
||||||
let blobDocumentType = blob.name
|
let blobDocumentType = blob.name
|
||||||
.split("/")[2]
|
.split("/")[2]
|
||||||
.slice(0, blob.name.split("/")[2].indexOf("_"));
|
.slice(0, blob.name.split("/")[2].indexOf("_"));
|
||||||
|
|
||||||
blobObj.push({
|
blobObj.push({
|
||||||
"name": blob.name.split("/")[2],
|
"name": fileName,
|
||||||
"path": blob.name,
|
"path": blob.name,
|
||||||
"documentType": getDocumentTypeFromFilename(
|
"documentType": getDocumentTypeFromFilename(fileName),
|
||||||
blob.name.split("/")[2]
|
|
||||||
),
|
|
||||||
"versionId": blob.versionId,
|
"versionId": blob.versionId,
|
||||||
"caseObj": casefolderID + "/" + casefolderID + "_case.json",
|
"caseObj": casefolderID + "/" + casefolderID + "_case.json",
|
||||||
"isCurrentVersion": blob.isCurrentVersion,
|
"isCurrentVersion": blob.isCurrentVersion,
|
||||||
@@ -294,7 +294,7 @@ export const getBlobs = async (containerName, casefolderID) => {
|
|||||||
...buildHashMetadataPaths({
|
...buildHashMetadataPaths({
|
||||||
containerName,
|
containerName,
|
||||||
casefolderID,
|
casefolderID,
|
||||||
blobname: blob.name.split("/")[2]
|
blobname: fileName
|
||||||
}),
|
}),
|
||||||
"deletepath":
|
"deletepath":
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
@@ -302,7 +302,7 @@ export const getBlobs = async (containerName, casefolderID) => {
|
|||||||
"&casefolderID=" +
|
"&casefolderID=" +
|
||||||
encodeURIComponent(casefolderID) +
|
encodeURIComponent(casefolderID) +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
encodeURIComponent(blob.name.split("/")[2])
|
encodeURIComponent(fileName)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//console.log("blobObj:", blobObj);
|
//console.log("blobObj:", blobObj);
|
||||||
@@ -1296,9 +1296,12 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
|||||||
for await (const blob of containerClient.listBlobsFlat({
|
for await (const blob of containerClient.listBlobsFlat({
|
||||||
prefix: caseReference + "/" + caseReference + "_appeal.json"
|
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({
|
blobObj.push({
|
||||||
"name": blob.name.split("/")[1],
|
"name": appealBlobName,
|
||||||
"path": blob.name,
|
"path": blob.name,
|
||||||
"versionId": blob.versionId,
|
"versionId": blob.versionId,
|
||||||
"caseObj": caseReference + "/" + caseReference + "_case.json",
|
"caseObj": caseReference + "/" + caseReference + "_case.json",
|
||||||
@@ -1309,7 +1312,7 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
|||||||
...buildHashMetadataPaths({
|
...buildHashMetadataPaths({
|
||||||
containerName,
|
containerName,
|
||||||
casefolderID: caseReference,
|
casefolderID: caseReference,
|
||||||
blobname: blob.name.split("/")[1]
|
blobname: appealBlobName
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1473,6 +1476,9 @@ export const getRepsFilesBlobs = async (
|
|||||||
for await (const blob of containerClient.listBlobsFlat({
|
for await (const blob of containerClient.listBlobsFlat({
|
||||||
prefix: casefolderID + "/" + filenamePrefix + "/files/"
|
prefix: casefolderID + "/" + filenamePrefix + "/files/"
|
||||||
})) {
|
})) {
|
||||||
|
const blobPathParts = blob.name.split("/");
|
||||||
|
const casefolderPath = blobPathParts[0] + "/" + blobPathParts[1];
|
||||||
|
const repFileName = blobPathParts[3];
|
||||||
let blobDocumentType = blob.name
|
let blobDocumentType = blob.name
|
||||||
.split("/")[2]
|
.split("/")[2]
|
||||||
.slice(0, blob.name.split("/")[2].indexOf("_"));
|
.slice(0, blob.name.split("/")[2].indexOf("_"));
|
||||||
@@ -1480,11 +1486,9 @@ export const getRepsFilesBlobs = async (
|
|||||||
console.log(blob.name);
|
console.log(blob.name);
|
||||||
|
|
||||||
blobObj.push({
|
blobObj.push({
|
||||||
"name": blob.name.split("/")[3],
|
"name": repFileName,
|
||||||
"path": blob.name,
|
"path": blob.name,
|
||||||
"documentType": getDocumentTypeFromFilename(
|
"documentType": getDocumentTypeFromFilename(repFileName),
|
||||||
blob.name.split("/")[3]
|
|
||||||
),
|
|
||||||
"versionId": blob.versionId,
|
"versionId": blob.versionId,
|
||||||
"isCurrentVersion": blob.isCurrentVersion,
|
"isCurrentVersion": blob.isCurrentVersion,
|
||||||
"contentLength": blob.properties.contentLength,
|
"contentLength": blob.properties.contentLength,
|
||||||
@@ -1493,26 +1497,21 @@ export const getRepsFilesBlobs = async (
|
|||||||
"/api/file/downloadblob?container=" +
|
"/api/file/downloadblob?container=" +
|
||||||
containerName +
|
containerName +
|
||||||
"&casefolderID=" +
|
"&casefolderID=" +
|
||||||
encodeURIComponent(
|
encodeURIComponent(casefolderPath) +
|
||||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
|
||||||
) +
|
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
encodeURIComponent(blob.name.split("/")[3]),
|
encodeURIComponent(repFileName),
|
||||||
...buildHashMetadataPaths({
|
...buildHashMetadataPaths({
|
||||||
containerName,
|
containerName,
|
||||||
casefolderID:
|
casefolderID: casefolderPath,
|
||||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1],
|
blobname: repFileName
|
||||||
blobname: blob.name.split("/")[3]
|
|
||||||
}),
|
}),
|
||||||
"deletepath":
|
"deletepath":
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
containerName +
|
containerName +
|
||||||
"&casefolderID=" +
|
"&casefolderID=" +
|
||||||
blob.name.split("/")[0] +
|
casefolderPath +
|
||||||
"/" +
|
|
||||||
blob.name.split("/")[1] +
|
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name.split("/")[3]
|
repFileName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log("blobObj:", blobObj);
|
console.log("blobObj:", blobObj);
|
||||||
|
|||||||
@@ -3007,3 +3007,34 @@ Validation:
|
|||||||
Follow-ups:
|
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.
|
- 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user