mirror of
https://github.com/hcengineering/platform.git
synced 2025-03-27 18:35:10 +00:00
fix: get rid of removeAllObjects by prefix (#6479)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
32335e066b
commit
f7d831a756
@ -176,11 +176,11 @@ export function createDummyStorageAdapter (): StorageAdapter {
|
|||||||
export async function removeAllObjects (
|
export async function removeAllObjects (
|
||||||
ctx: MeasureContext,
|
ctx: MeasureContext,
|
||||||
storage: StorageAdapter,
|
storage: StorageAdapter,
|
||||||
workspaceId: WorkspaceId,
|
workspaceId: WorkspaceId
|
||||||
prefix?: string
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
ctx.warn('removing all objects from workspace', { workspaceId })
|
||||||
// We need to list all files and delete them
|
// 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[] = []
|
let bulk: string[] = []
|
||||||
while (true) {
|
while (true) {
|
||||||
const obj = await iterator.next()
|
const obj = await iterator.next()
|
||||||
|
@ -47,7 +47,7 @@ import core, {
|
|||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import notification, { Collaborators } from '@hcengineering/notification'
|
import notification, { Collaborators } from '@hcengineering/notification'
|
||||||
import { getMetadata } from '@hcengineering/platform'
|
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'
|
import { workbenchId } from '@hcengineering/workbench'
|
||||||
|
|
||||||
export async function OnSpaceTypeMembers (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
export async function OnSpaceTypeMembers (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||||
@ -181,12 +181,6 @@ export async function OnContactDelete (
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removeContact.avatar == null) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
await removeAllObjects(ctx, storageAdapter, workspace, removeContact.avatar)
|
|
||||||
|
|
||||||
const result: Tx[] = []
|
const result: Tx[] = []
|
||||||
|
|
||||||
const members = await findAll(contact.class.Member, { contact: removeContact._id })
|
const members = await findAll(contact.class.Member, { contact: removeContact._id })
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import { Analytics } from '@hcengineering/analytics'
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import { MeasureContext, Blob as PlatformBlob, WorkspaceId, metricsAggregate, type Ref } from '@hcengineering/core'
|
import { MeasureContext, Blob as PlatformBlob, WorkspaceId, metricsAggregate, type Ref } from '@hcengineering/core'
|
||||||
import { Token, decodeToken } from '@hcengineering/server-token'
|
import { Token, decodeToken } from '@hcengineering/server-token'
|
||||||
import { StorageAdapter, removeAllObjects } from '@hcengineering/storage'
|
import { StorageAdapter } from '@hcengineering/storage'
|
||||||
import bp from 'body-parser'
|
import bp from 'body-parser'
|
||||||
import cors from 'cors'
|
import cors from 'cors'
|
||||||
import express, { Request, Response } from 'express'
|
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)
|
// 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])
|
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()
|
res.status(200).send()
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
Analytics.handleError(error)
|
Analytics.handleError(error)
|
||||||
|
Loading…
Reference in New Issue
Block a user