fix: scale folder upload timeout by file size (fixes #249)

The folder upload path (uploadFolderEntries) used a flat 10s fetch
timeout for all files regardless of size. Large files like .CR2 RAW
images (~25MB) on slower networks (e.g. Raspberry Pi) exceeded this
timeout, causing the AbortController to kill the request before the
server received the full body — hence no server logs and 'unknown
error' on the frontend.

Changed to size-scaled timeout: 30s base + 2s per MB (min 10s).
A 25MB CR2 now gets ~80s instead of 10s.
This commit is contained in:
Diocrafts
2026-04-12 00:29:34 +02:00
parent eab1143324
commit e91dcee0ea
2 changed files with 6 additions and 5 deletions
-3
View File
@@ -16,10 +16,7 @@
[![Last Commit](https://img.shields.io/github/last-commit/diocrafts/OxiCloud?style=for-the-badge)](https://github.com/diocrafts/OxiCloud/commits/main)
[**Documentation**](https://diocrafts.github.io/OxiCloud/) | [**Quick Start**](#-quick-start)
<br>
**English** | [Español](docs/es/)
</div>
NextCloud was too slow on my home server. So I built OxiCloud — a complete cloud platform written in Rust that runs on minimal hardware and stays out of your way.
+6 -2
View File
@@ -549,7 +549,9 @@ const fileOps = {
// so all files reaching fetch() are regular. Keep-alive
// reuses TCP connections across workers for speed.
const CONCURRENCY = 10;
const TIMEOUT_MS = 10000; // 10s for normal files
const TIMEOUT_BASE_MS = 30000; // 30s base for normal files
const TIMEOUT_PER_MB_MS = 2000; // +2s per MB (supports ≥4 Mbps)
const TIMEOUT_MIN_MS = 10000; // floor for tiny files
const TIMEOUT_MS_ZERO = 3000; // 3s for 0-byte files
const uploadOneFile = async (idx) => {
@@ -596,7 +598,9 @@ const fileOps = {
formData.append('folder_id', targetFolderId);
formData.append('file', uploadFile, file.name);
const thisTimeout = file.size === 0 ? TIMEOUT_MS_ZERO : TIMEOUT_MS;
const thisTimeout = file.size === 0
? TIMEOUT_MS_ZERO
: Math.max(TIMEOUT_MIN_MS, TIMEOUT_BASE_MS + Math.ceil(file.size / (1024 * 1024)) * TIMEOUT_PER_MB_MS);
console.log(`[UPLOAD START] #${idx} ${rel} (${file.size} bytes, timeout=${thisTimeout}ms)`);
result = await this._uploadFileFetch(formData, thisTimeout);