fix: get rid of removeAllObjects by prefix (#6479)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-09-04 02:32:22 +07:00 committed by Andrey Sobolev
parent 32335e066b
commit f7d831a756
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
3 changed files with 5 additions and 15 deletions

View File

@ -176,11 +176,11 @@ export function createDummyStorageAdapter (): StorageAdapter {
export async function removeAllObjects (
ctx: MeasureContext,
storage: StorageAdapter,
workspaceId: WorkspaceId,
prefix?: string
workspaceId: WorkspaceId
): Promise<void> {
ctx.warn('removing all objects from workspace', { workspaceId })
// We need to list all files and delete them
const iterator = await storage.listStream(ctx, workspaceId, prefix)
const iterator = await storage.listStream(ctx, workspaceId)
let bulk: string[] = []
while (true) {
const obj = await iterator.next()

View File

@ -47,7 +47,7 @@ import core, {
} from '@hcengineering/core'
import notification, { Collaborators } from '@hcengineering/notification'
import { getMetadata } from '@hcengineering/platform'
import serverCore, { TriggerControl, removeAllObjects } from '@hcengineering/server-core'
import serverCore, { TriggerControl } from '@hcengineering/server-core'
import { workbenchId } from '@hcengineering/workbench'
export async function OnSpaceTypeMembers (tx: Tx, control: TriggerControl): Promise<Tx[]> {
@ -181,12 +181,6 @@ export async function OnContactDelete (
return []
}
if (removeContact.avatar == null) {
return []
}
await removeAllObjects(ctx, storageAdapter, workspace, removeContact.avatar)
const result: Tx[] = []
const members = await findAll(contact.class.Member, { contact: removeContact._id })

View File

@ -17,7 +17,7 @@
import { Analytics } from '@hcengineering/analytics'
import { MeasureContext, Blob as PlatformBlob, WorkspaceId, metricsAggregate, type Ref } from '@hcengineering/core'
import { Token, decodeToken } from '@hcengineering/server-token'
import { StorageAdapter, removeAllObjects } from '@hcengineering/storage'
import { StorageAdapter } from '@hcengineering/storage'
import bp from 'body-parser'
import cors from 'cors'
import express, { Request, Response } from 'express'
@ -545,10 +545,6 @@ export function start (
// TODO: We need to allow delete only of user attached documents. (https://front.hc.engineering/workbench/platform/tracker/TSK-1081)
await config.storageAdapter.remove(ctx, payload.workspace, [uuid])
// TODO: Add support for related documents.
// TODO: Move support of image resize/format change to separate place.
await removeAllObjects(ctx, config.storageAdapter, payload.workspace, uuid)
res.status(200).send()
} catch (error: any) {
Analytics.handleError(error)