feat: add configurable parallel video uploads
Allow up to four video upload connections while keeping one connection as the default. Preserve existing messaging interfaces and add configuration controls, reliable failure handling, and upload diagnostics. Closes #569
This commit is contained in:
18 files changed
+1182
-217
No files matched your search
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
getVideoUploadConcurrency,
|
||||
setVideoUploadConcurrency,
|
||||
} from '@snowluma/protocol/highway/upload-settings';
|
||||
// video-upload tests cover the fingerprint (fast-upload) path. The
|
||||
// regular load path exercises ffmpeg + the OS temp dir + a streaming
|
||||
// SHA1 implementation; that machinery has its own seams worth testing
|
||||
@@ -9,7 +13,7 @@
|
||||
// fastOnlyError difference (main has it; thumb doesn't — FALLBACK_THUMB
|
||||
// always provides bytes), and the video-specific OIDB fields.
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { promises as fsp } from 'fs';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
@@ -44,11 +48,27 @@ const FINGERPRINT = {
|
||||
} as any;
|
||||
|
||||
describe('video-upload', () => {
|
||||
afterEach(() => setVideoUploadConcurrency(1));
|
||||
beforeEach(() => {
|
||||
vi.mocked(pipeline.runNtv2Upload).mockClear();
|
||||
vi.mocked(pipeline.finalizeMediaMsgInfo).mockClear();
|
||||
});
|
||||
|
||||
it('snapshots the global concurrency for video bodies without parallelizing covers', async () => {
|
||||
expect(getVideoUploadConcurrency()).toBe(1);
|
||||
setVideoUploadConcurrency(4);
|
||||
const first = uploadVideoMsgInfo({} as any, true, 12345, FINGERPRINT);
|
||||
setVideoUploadConcurrency(2);
|
||||
await first;
|
||||
const firstUpload = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0];
|
||||
expect(firstUpload.uploads[0]!.concurrency).toBe(4);
|
||||
expect(firstUpload.uploads[1]!.concurrency).toBeUndefined();
|
||||
await uploadVideoMsgInfo({} as any, false, 'recipient-uid', FINGERPRINT);
|
||||
const secondUpload = vi.mocked(pipeline.runNtv2Upload).mock.calls[1]![0];
|
||||
expect(secondUpload.uploads[0]!.concurrency).toBe(2);
|
||||
expect(secondUpload.uploads[1]!.concurrency).toBeUndefined();
|
||||
});
|
||||
|
||||
it('retains successful upload metadata for self-sent history', async () => {
|
||||
const node = { fileUuid: 'uploaded-resource', storeId: 1, info: { fileSize: 1234 } };
|
||||
vi.mocked(pipeline.runNtv2Upload).mockResolvedValueOnce({
|
||||
|
||||
Reference in new issue
Block a user