fix(clouddrop): never throw after all chunks uploaded
/upload/complete was failing (non-JSON response, missing fileId, or post-processing timeout) after all bytes were already on the server, causing upload-manager to retry the entire multi-GB upload — which corrupts the server-side file since two uploads end up interleaved. Now /complete failures are swallowed and sessionId is used as the file_code fallback. Upload is considered done once all chunks are in.
This commit is contained in:
parent
215a10186e
commit
79cf8ad002
@ -190,7 +190,11 @@ class ClouddropUploader {
|
|||||||
try { fs.closeSync(fd); } catch {}
|
try { fs.closeSync(fd); } catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Complete session
|
// 3. Complete session — all bytes are already on the server at this point.
|
||||||
|
// We MUST NOT throw here, otherwise the upload-manager would retry the entire
|
||||||
|
// multi-GB upload. Any failure (timeout, non-JSON, missing fileId, server still
|
||||||
|
// post-processing) is swallowed and we fall back to sessionId as file_code.
|
||||||
|
try {
|
||||||
const completeRes = await request(`${API_BASE}/upload/${sessionId}/complete`, {
|
const completeRes = await request(`${API_BASE}/upload/${sessionId}/complete`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dispatcher: clouddropAgent,
|
dispatcher: clouddropAgent,
|
||||||
@ -200,10 +204,11 @@ class ClouddropUploader {
|
|||||||
headersTimeout: COMPLETE_TIMEOUT,
|
headersTimeout: COMPLETE_TIMEOUT,
|
||||||
bodyTimeout: COMPLETE_TIMEOUT
|
bodyTimeout: COMPLETE_TIMEOUT
|
||||||
});
|
});
|
||||||
const completePayload = await this._parseJsonResponse(completeRes);
|
const completePayload = await this._parseJsonResponse(completeRes).catch(() => ({}));
|
||||||
const fileId = completePayload.fileId || completePayload.id;
|
return completePayload.fileId || completePayload.id || sessionId;
|
||||||
if (!fileId) throw new Error('Clouddrop: Keine fileId in /upload/complete Antwort');
|
} catch {
|
||||||
return fileId;
|
return sessionId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user