fix provider selection in aggregator (#6365)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2024-08-21 18:20:18 +07:00
committed by GitHub
parent af332c6beb
commit 1bf50e1128
4 changed files with 14 additions and 12 deletions
+11 -3
View File
@@ -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) {
@@ -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) {