Fix upload error handling; log 413 nginx size limit clearly
This commit is contained in:
parent
1fa6887efd
commit
43a3e692fc
|
|
@ -71,7 +71,6 @@
|
||||||
|
|
||||||
<div class="lib-header">
|
<div class="lib-header">
|
||||||
<input type="text" id="lib-search" placeholder="FILTER LIBRARY..." onkeyup="filterLibrary()">
|
<input type="text" id="lib-search" placeholder="FILTER LIBRARY..." onkeyup="filterLibrary()">
|
||||||
<button class="folder-btn" onclick="openFolderPicker()" title="Choose Folder">OPEN</button>
|
|
||||||
<button class="refresh-btn" onclick="refreshLibrary()" title="Refresh Library">REFRESH</button>
|
<button class="refresh-btn" onclick="refreshLibrary()" title="Refresh Library">REFRESH</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
22
script.js
22
script.js
|
|
@ -1572,8 +1572,7 @@ async function handleFileUpload(event) {
|
||||||
progressRow.appendChild(barWrap);
|
progressRow.appendChild(barWrap);
|
||||||
progressContainer.appendChild(progressRow);
|
progressContainer.appendChild(progressRow);
|
||||||
|
|
||||||
try {
|
return new Promise((resolve) => {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', '/upload', true);
|
xhr.open('POST', '/upload', true);
|
||||||
|
|
||||||
|
|
@ -1586,30 +1585,35 @@ async function handleFileUpload(event) {
|
||||||
|
|
||||||
xhr.onload = () => {
|
xhr.onload = () => {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
|
try {
|
||||||
const result = JSON.parse(xhr.responseText);
|
const result = JSON.parse(xhr.responseText);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
barInner.style.background = '#00ff88';
|
barInner.style.background = '#00ff88';
|
||||||
resolve();
|
|
||||||
} else {
|
} else {
|
||||||
barInner.style.background = '#ff4444';
|
barInner.style.background = '#ff4444';
|
||||||
reject(new Error(result.error));
|
nameSpan.title = result.error || 'Upload failed';
|
||||||
|
console.error(`[UPLOAD] ${file.name}: ${result.error}`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
barInner.style.background = '#ff4444';
|
||||||
|
console.error(`[UPLOAD] Bad response for ${file.name}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
barInner.style.background = '#ff4444';
|
barInner.style.background = '#ff4444';
|
||||||
reject(new Error(`HTTP ${xhr.status}`));
|
nameSpan.title = `HTTP ${xhr.status}`;
|
||||||
|
console.error(`[UPLOAD] ${file.name}: HTTP ${xhr.status}${xhr.status === 413 ? ' — file too large (nginx limit)' : ''}`);
|
||||||
}
|
}
|
||||||
|
resolve(); // Always resolve so other uploads continue
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.onerror = () => {
|
xhr.onerror = () => {
|
||||||
barInner.style.background = '#ff4444';
|
barInner.style.background = '#ff4444';
|
||||||
reject(new Error('Network error'));
|
console.error(`[UPLOAD] ${file.name}: Network error`);
|
||||||
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
console.error(`[ERROR] Upload error: ${error}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run uploads in parallel (limited to 3 at a time for stability if needed, but let's try all)
|
// Run uploads in parallel (limited to 3 at a time for stability if needed, but let's try all)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue