Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-7165: Storage + Backup improvements #5913

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions dev/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,28 @@ export function devTool (
.description('dump workspace transactions and minio resources')
.option('-i, --include <include>', 'A list of ; separated domain names to include during backup', '*')
.option('-s, --skip <skip>', 'A list of ; separated domain names to skip during backup', '')
.option(
'-ct, --contentTypes <contentTypes>',
'A list of ; separated content types for blobs to skip download if size >= limit',
''
)
.option('-bl, --blobLimit <blobLimit>', 'A blob size limit in megabytes (default 15mb)', '15')
.option('-f, --force', 'Force backup', false)
.option('-c, --recheck', 'Force hash recheck on server', false)
.option('-t, --timeout <timeout>', 'Connect timeout in seconds', '30')
.action(
async (
dirName: string,
workspace: string,
cmd: { skip: string, force: boolean, recheck: boolean, timeout: string, include: string }
cmd: {
skip: string
force: boolean
recheck: boolean
timeout: string
include: string
blobLimit: string
contentTypes: string
}
) => {
const storage = await createFileBackupStorage(dirName)
await backup(toolCtx, transactorUrl, getWorkspaceId(workspace, productId), storage, {
Expand All @@ -608,7 +622,12 @@ export function devTool (
include: cmd.include === '*' ? undefined : new Set(cmd.include.split(';').map((it) => it.trim())),
skipDomains: (cmd.skip ?? '').split(';').map((it) => it.trim()),
timeout: 0,
connectTimeout: parseInt(cmd.timeout) * 1000
connectTimeout: parseInt(cmd.timeout) * 1000,
blobDownloadLimit: parseInt(cmd.blobLimit),
skipBlobContentTypes: cmd.contentTypes
.split(';')
.map((it) => it.trim())
.filter((it) => it.length > 0)
})
}
)
Expand Down
2 changes: 1 addition & 1 deletion models/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ export class TAttachedDoc extends TDoc implements AttachedDoc {
export class TBlob extends TDoc implements Blob {
@Prop(TypeString(), core.string.Blob)
@ReadOnly()
@Index(IndexKind.Indexed)
provider!: string

@Prop(TypeString(), core.string.BlobContentType)
@ReadOnly()
@Index(IndexKind.Indexed)
contentType!: string

@Prop(TypeString(), core.string.BlobStorageId)
Expand Down
8 changes: 4 additions & 4 deletions models/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ import {
TSpace,
TSpaceType,
TSpaceTypeDescriptor,
TTypedSpace,
TSystemSpace
TSystemSpace,
TTypedSpace
} from './security'
import { TStatus, TStatusCategory, TDomainStatusPlaceholder } from './status'
import { defineSpaceType } from './spaceType'
import { TDomainStatusPlaceholder, TStatus, TStatusCategory } from './status'
import { TUserStatus } from './transient'
import {
TTx,
Expand All @@ -103,7 +104,6 @@ import {
TTxUpdateDoc,
TTxWorkspaceEvent
} from './tx'
import { defineSpaceType } from './spaceType'

export { coreId } from '@hcengineering/core'
export * from './core'
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default plugin(presentationId, {
CollaboratorApiUrl: '' as Metadata<string>,
Token: '' as Metadata<string>,
FrontUrl: '' as Asset,
PreviewConfig: '' as Metadata<PreviewConfig>
PreviewConfig: '' as Metadata<PreviewConfig | undefined>
},
status: {
FileTooLarge: '' as StatusCode
Expand Down
33 changes: 17 additions & 16 deletions packages/presentation/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,9 @@ const defaultPreview = (): ProviderPreviewConfig => ({
- contentTypes - a ',' separated list of content type patterns.

*/
export function parsePreviewConfig (config?: string): PreviewConfig {
export function parsePreviewConfig (config?: string): PreviewConfig | undefined {
if (config === undefined) {
// TODO: Remove after all migrated
return {
default: defaultPreview(),
previewers: {
'': [
{
providerId: '',
contentTypes: ['image/gif', 'image/apng', 'image/svg'], // Disable gif and apng format preview.
formats: [],
previewUrl: ''
}
]
}
}
return
}
const result: PreviewConfig = { previewers: {} }
const nolineData = config
Expand Down Expand Up @@ -99,7 +86,21 @@ export function parsePreviewConfig (config?: string): PreviewConfig {
}

export function getPreviewConfig (): PreviewConfig {
return getMetadata(presentation.metadata.PreviewConfig) as PreviewConfig
return (
(getMetadata(presentation.metadata.PreviewConfig) as PreviewConfig) ?? {
default: defaultPreview(),
previewers: {
'': [
{
providerId: '',
contentTypes: ['image/gif', 'image/apng', 'image/svg'], // Disable gif and apng format preview.
formats: [],
previewUrl: ''
}
]
}
}
)
}

export async function getBlobRef (
Expand Down
2 changes: 1 addition & 1 deletion packages/query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ export class LiveQuery implements WithTx, Client {
} else {
const d = await this.findOne(lookupClass, { _id: pops[pkey] }, { lookup: nestedLookup })
if (d !== undefined) {
pp[pkey].push()
pp[pkey].push(d)
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions packages/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

import {
type Blob,
type Branding,
type DocumentUpdate,
type MeasureContext,
type Ref,
type StorageIterator,
type WorkspaceId,
type WorkspaceIdWithUrl,
type Branding
type WorkspaceIdWithUrl
} from '@hcengineering/core'
import type { BlobLookup } from '@hcengineering/core/src/classes'
import { type Readable } from 'stream'
Expand Down Expand Up @@ -103,6 +104,8 @@ export interface StorageAdapterEx extends StorageAdapter {
objectName: string,
provider?: string
) => Promise<void>

find: (ctx: MeasureContext, workspaceId: WorkspaceId) => StorageIterator
}

/**
Expand All @@ -120,6 +123,13 @@ export class DummyStorageAdapter implements StorageAdapter, StorageAdapterEx {
return false
}

find (ctx: MeasureContext, workspaceId: WorkspaceId): StorageIterator {
return {
next: async (ctx) => undefined,
close: async (ctx) => {}
}
}

async listBuckets (ctx: MeasureContext, productId: string): Promise<BucketInfo[]> {
return []
}
Expand Down
2 changes: 1 addition & 1 deletion packages/text/src/nodes/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const ImageNode = Node.create<ImageOptions>({
if (fileId != null) {
const setBrokenImg = setTimeout(() => {
imgElement.src = this.options.loadingImgSrc ?? `platform://platform/files/workspace/?file=${fileId}`
}, 200)
}, 500)
if (fileId != null) {
void this.options.getBlobRef(fileId).then((val) => {
clearTimeout(setBrokenImg)
Expand Down
Loading