Release v2.1.65: safe MCP updates and measured upload scheduling
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-16 05:36:42 +02:00
1 parent e3c03d195e
commit 1ff552fc40
26 files changed
+552 -92

No files matched your search

+7 -9
View File
@@ -1,4 +1,4 @@
const fs = require('fs');
const { statUploadFile, readUploadFile } = require('./upload-file-io');
const path = require('path');
const crypto = require('crypto');
const { request } = require('undici');
@@ -259,10 +259,10 @@ function parseByseResult(payload) {
// --- Multipart upload with progress ---
function buildMultipart(filePath, formFields) {
async function buildMultipart(filePath, formFields) {
const boundary = '----FormBoundary' + crypto.randomBytes(16).toString('hex');
const fileName = path.basename(filePath);
const fileSize = fs.statSync(filePath).size;
const fileSize = (await statUploadFile(filePath)).size;
let preamble = '';
for (const [key, value] of Object.entries(formFields)) {
@@ -284,16 +284,14 @@ function buildMultipart(filePath, formFields) {
return { boundary, preambleBuf, epilogueBuf, totalSize, fileSize };
}
function createUploadBody(filePath, formFields, onProgress, throttle, signal) {
const { boundary, preambleBuf, epilogueBuf, totalSize, fileSize } = buildMultipart(filePath, formFields);
async function createUploadBody(filePath, formFields, onProgress, throttle, signal) {
const { boundary, preambleBuf, epilogueBuf, totalSize, fileSize } = await buildMultipart(filePath, formFields);
let bytesRead = 0;
const CHUNK_SIZE = 1024 * 1024;
async function* generate() {
yield preambleBuf;
const fileStream = fs.createReadStream(filePath, { highWaterMark: CHUNK_SIZE });
for await (const chunk of fileStream) {
for await (const chunk of readUploadFile(filePath, signal)) {
if (signal && signal.aborted) throw new Error('Aborted');
if (throttle) await throttle.consume(chunk.length, signal);
bytesRead += chunk.length;
@@ -558,7 +556,7 @@ async function uploadFile(hosterName, filePath, apiKey, onProgress, signal, thro
const targetUrl = config.buildUploadUrl(uploadUrl, apiKey);
const formFields = config.formFields(apiKey);
const { iterable, boundary, totalSize } = createUploadBody(filePath, formFields, onProgress, throttle, signal);
const { iterable, boundary, totalSize } = await createUploadBody(filePath, formFields, onProgress, throttle, signal);
const { body, statusCode, headers } = await request(targetUrl, {
method: 'POST',