Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3514355
D13513.id44666.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
D13513.id44666.diff
View Options
diff --git a/keyserver/src/deleters/thread-deleters.js b/keyserver/src/deleters/thread-deleters.js
--- a/keyserver/src/deleters/thread-deleters.js
+++ b/keyserver/src/deleters/thread-deleters.js
@@ -1,6 +1,7 @@
// @flow
import { permissionLookup } from 'lib/permissions/thread-permissions.js';
+import type { BlobHashAndHolder } from 'lib/types/holder-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import {
type ThreadDeletionRequest,
@@ -18,7 +19,9 @@
import { fetchThreadPermissionsBlob } from '../fetchers/thread-permission-fetchers.js';
import { fetchUpdateInfoForThreadDeletion } from '../fetchers/update-fetchers.js';
import { rescindPushNotifs } from '../push/rescind.js';
+import { removeBlobHolders } from '../services/blob.js';
import type { Viewer } from '../session/viewer.js';
+import { blobHoldersFromUploadRows } from '../uploads/media-utils.js';
type DeleteThreadOptions = Partial<{
+ignorePermissions: boolean,
@@ -81,14 +84,28 @@
}
}
+ const blobHolders = await fetchThreadBlobHoldersToDelete(threadIDs);
const [{ viewerUpdates }] = await Promise.all([
createUpdates(updateDatas, { viewer, updatesForCurrentSession: 'return' }),
deleteThreadsFromDB(threadIDs),
+ removeBlobHolders(blobHolders),
]);
return { updatesResult: { newUpdates: viewerUpdates } };
}
+async function fetchThreadBlobHoldersToDelete(
+ threadIDs: $ReadOnlyArray<string>,
+): Promise<$ReadOnlyArray<BlobHashAndHolder>> {
+ const query = SQL`
+ SELECT extra
+ FROM uploads
+ WHERE container IN (${threadIDs});
+ `;
+ const [rows] = await dbQuery(query);
+ return blobHoldersFromUploadRows(rows);
+}
+
function deleteThreadsFromDB(
threadIDs: $ReadOnlyArray<string>,
): Promise<mixed> {
@@ -144,7 +161,12 @@
if (threadIDs.size === 0) {
return;
}
- await deleteThreadsFromDB([...threadIDs]);
+ const containerIDs = [...threadIDs];
+ const blobHolders = await fetchThreadBlobHoldersToDelete(containerIDs);
+ await Promise.all([
+ deleteThreadsFromDB(containerIDs),
+ removeBlobHolders(blobHolders),
+ ]);
}
export { deleteThread, deleteInaccessibleThreads };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 4:27 AM (16 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693545
Default Alt Text
D13513.id44666.diff (2 KB)
Attached To
Mode
D13513: [keyserver] Remove holders in thread deleters
Attached
Detach File
Event Timeline
Log In to Comment