Tool recruit update (#1035)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2022-02-23 10:09:07 +01:00
committed by GitHub
parent 2691ac930e
commit 5a74bda519
9 changed files with 319 additions and 33 deletions
+21 -16
View File
@@ -77,22 +77,7 @@ export async function dumpWorkspace (mongoUrl: string, dbName: string, fileName:
const fileHandle = await open(join(minioDbLocation, d.name), 'w')
const data = await minio.getObject(dbName, d.name)
const chunks: Buffer[] = []
await new Promise((resolve) => {
data.on('readable', () => {
let chunk
while ((chunk = data.read()) !== null) {
const b = chunk as Buffer
chunks.push(b)
}
})
data.on('end', () => {
resolve(null)
})
})
const chunks: Buffer[] = await readMinioData(minio, dbName, d.name)
for (const b of chunks) {
await fileHandle.write(b)
}
@@ -106,6 +91,26 @@ export async function dumpWorkspace (mongoUrl: string, dbName: string, fileName:
}
}
export async function readMinioData (minio: Client, dbName: string, name: string): Promise<Buffer[]> {
const data = await minio.getObject(dbName, name)
const chunks: Buffer[] = []
await new Promise((resolve) => {
data.on('readable', () => {
let chunk
while ((chunk = data.read()) !== null) {
const b = chunk as Buffer
chunks.push(b)
}
})
data.on('end', () => {
resolve(null)
})
})
return chunks
}
export async function restoreWorkspace (
mongoUrl: string,
dbName: string,