Use TUS utilities for backup upload

This commit is contained in:
Fedor Indutny 2024-05-14 10:04:50 -07:00 committed by GitHub
parent 4eb5458ace
commit 4fed756661
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 356 additions and 228 deletions

View file

@ -3,7 +3,8 @@
import path from 'path';
import { tmpdir } from 'os';
import { rmSync, mkdtempSync, createReadStream } from 'fs';
import { createReadStream } from 'fs';
import { mkdtemp, rm } from 'fs/promises';
import { v4 as generateGuid } from 'uuid';
import { assert } from 'chai';
@ -71,7 +72,7 @@ async function asymmetricRoundtripHarness(
before: Array<MessageAttributesType>,
after: Array<MessageAttributesType>
) {
const outDir = mkdtempSync(path.join(tmpdir(), 'signal-temp-'));
const outDir = await mkdtemp(path.join(tmpdir(), 'signal-temp-'));
try {
const targetOutputFile = path.join(outDir, 'backup.bin');
@ -89,7 +90,7 @@ async function asymmetricRoundtripHarness(
const actual = sortAndNormalize(messagesFromDatabase);
assert.deepEqual(expected, actual);
} finally {
rmSync(outDir, { recursive: true });
await rm(outDir, { recursive: true });
}
}