Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3522567
D10098.id34055.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10098.id34055.diff
View Options
diff --git a/keyserver/src/push/utils.js b/keyserver/src/push/utils.js
--- a/keyserver/src/push/utils.js
+++ b/keyserver/src/push/utils.js
@@ -408,7 +408,10 @@
try {
const { encryptionKey, encryptedPayload, encryptedPayloadHash } =
await encryptBlobPayload(payload);
- await upload(encryptedPayload, encryptedPayloadHash, blobHolder);
+ await upload(encryptedPayload, {
+ hash: encryptedPayloadHash,
+ holder: blobHolder,
+ });
return {
blobHash: encryptedPayloadHash,
encryptionKey,
diff --git a/keyserver/src/services/blob.js b/keyserver/src/services/blob.js
--- a/keyserver/src/services/blob.js
+++ b/keyserver/src/services/blob.js
@@ -7,6 +7,11 @@
} from 'lib/utils/blob-service.js';
import { getMessageForException } from 'lib/utils/errors.js';
+type BlobDescriptor = {
+ +hash: string,
+ +holder: string,
+};
+
async function uploadBlob(blob: Blob, hash: string): Promise<void> {
const formData = new FormData();
formData.append('blob_hash', hash);
@@ -26,7 +31,7 @@
}
}
-async function assignHolder(holder: string, hash: string): Promise<void> {
+async function assignHolder({ hash, holder }: BlobDescriptor): Promise<void> {
const assignHolderResponse = await fetch(
makeBlobServiceEndpointURL(blobService.httpEndpoints.ASSIGN_HOLDER),
{
@@ -49,9 +54,12 @@
}
}
-async function upload(blob: Blob, hash: string, holder: string): Promise<void> {
+async function upload(
+ blob: Blob,
+ { hash, holder }: BlobDescriptor,
+): Promise<void> {
try {
- await Promise.all([assignHolder(holder, hash), uploadBlob(blob, hash)]);
+ await Promise.all([assignHolder({ hash, holder }), uploadBlob(blob, hash)]);
} catch (e) {
throw new Error(
`Payload upload failed with: ${
@@ -85,11 +93,7 @@
return { found: true, blob };
}
-type DeleteBlobParams = {
- +hash: string,
- +holder: string,
-};
-async function deleteBlob({ hash, holder }: DeleteBlobParams) {
+async function deleteBlob({ hash, holder }: BlobDescriptor) {
const endpoint = blobService.httpEndpoints.DELETE_BLOB;
const url = makeBlobServiceEndpointURL(endpoint);
await fetch(url, {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 7:03 AM (15 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698867
Default Alt Text
D10098.id34055.diff (2 KB)
Attached To
Mode
D10098: [keyserver] Modify blob functions so that they take params object where both hash and holder are provided
Attached
Detach File
Event Timeline
Log In to Comment