Skip to content
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
14 changes: 11 additions & 3 deletions dev/tool/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function moveFiles (

for (const [name, adapter] of exAdapter.adapters.entries()) {
if (name === target) continue
console.log('moving from', name)

const iterator = await adapter.listStream(ctx, workspaceId)
while (true) {
Expand All @@ -44,9 +45,16 @@ export async function moveFiles (
if (blob === undefined) continue
if (blob.provider === target) continue

const readable = await exAdapter.get(ctx, workspaceId, data._id)
const stream = readable.pipe(new PassThrough())
await exAdapter.put(ctx, workspaceId, data._id, stream, blob.contentType, blob.size)
try {
const readable = await exAdapter.get(ctx, workspaceId, data._id)
readable.on('end', () => {
readable.destroy()
})
const stream = readable.pipe(new PassThrough())
await exAdapter.put(ctx, workspaceId, data._id, stream, blob.contentType, blob.size)
} catch (err) {
console.error('failed to process blob', name, data._id, err)
}

count += 1
if (count % 100 === 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function getFileUrl (file: string, filename?: string): string {

const template = getFilesUrl()
return template
.replaceAll(':filename', encodeURIComponent(filename ?? ''))
.replaceAll(':filename', encodeURIComponent(filename ?? file))
.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspace()))
.replaceAll(':blobId', encodeURIComponent(file))
}
Expand Down
2 changes: 0 additions & 2 deletions packages/presentation/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ function blobToSrcSet (cfg: PreviewConfig, blob: Ref<Blob>, width: number | unde
' 2x, ' +
fu.replaceAll(':size', `${width * 3}`) +
' 3x'
} else {
result += downloadUrl
}

return result
Expand Down
8 changes: 2 additions & 6 deletions server/core/src/server/aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,8 @@ export class AggregatorStorageAdapter implements StorageAdapter, StorageAdapterE

@withContext('aggregator-get', {})
async get (ctx: MeasureContext, workspaceId: WorkspaceId, name: string): Promise<Readable> {
// const { provider, stat } = await this.findProvider(ctx, workspaceId, name)
const provider = this.adapters.get(this.defaultAdapter)
if (provider === undefined) {
throw new NoSuchKeyError('No such provider found')
}
return await provider.get(ctx, workspaceId, name)
const { provider, stat } = await this.findProvider(ctx, workspaceId, name)
return await provider.get(ctx, workspaceId, stat.storageId)
}

@withContext('find-provider', {})
Expand Down