Publish #1

Merged
IgorVolochay merged 29 commits from dev into main 2026-01-10 16:02:13 +00:00
3 changed files with 30 additions and 13 deletions
Showing only changes of commit 15977f79e9 - Show all commits
+1 -2
View File
@@ -42,9 +42,8 @@
<div class="page-content"> <div class="page-content">
<h1>Скачать файл</h1> <h1>Скачать файл</h1>
<div class="upload-container"> <div class="upload-container">
<div id="downloadContent">
<div class="status" id="downloadStatus">Загрузка...</div> <div class="status" id="downloadStatus">Загрузка...</div>
</div> <div id="downloadContent"></div>
</div> </div>
</div> </div>
</div> </div>
+24 -10
View File
@@ -11,7 +11,8 @@ function formatBytes(bytes) {
// Check if we're on the download page // Check if we're on the download page
const path = window.location.pathname; const path = window.location.pathname;
const downloadMatch = path.match(/^\/get\/([a-zA-Z0-9]{6})$/); // Match /get/ followed by any alphanumeric characters (not just exactly 6)
const downloadMatch = path.match(/^\/get\/([a-zA-Z0-9]+)$/);
if (downloadMatch) { if (downloadMatch) {
// Show download page // Show download page
@@ -32,28 +33,41 @@ async function handleDownloadPage(fileUuid) {
const downloadStatus = document.getElementById('downloadStatus'); const downloadStatus = document.getElementById('downloadStatus');
const downloadContent = document.getElementById('downloadContent'); const downloadContent = document.getElementById('downloadContent');
// Check UUID length first (must be exactly 6 characters)
if (fileUuid.length !== 6) {
downloadStatus.textContent = 'Мы не смогли ничего найти.\nПерепроверьте введенный адрес.';
downloadStatus.className = 'status error';
downloadStatus.style.display = 'block';
downloadContent.innerHTML = '';
return;
}
// Show loading state
downloadStatus.textContent = 'Загрузка...';
downloadStatus.className = 'status';
downloadStatus.style.display = 'block';
downloadContent.innerHTML = '';
try { try {
const response = await fetch(`/api/get_download_link/${fileUuid}`); const response = await fetch(`/api/get_download_link/${fileUuid}`);
// Check for network/connection errors // Check for network/connection errors
if (!response.ok && (response.status === 0 || response.status >= 500)) { if (!response.ok && (response.status === 0 || response.status >= 500)) {
downloadStatus.textContent = 'Сервис временно недоступен, приносим наши извинения.'; downloadStatus.textContent = 'Сервис временно недоступен,\nприносим наши извинения.';
downloadStatus.className = 'status error'; downloadStatus.className = 'status error';
downloadStatus.style.display = 'block'; downloadStatus.style.display = 'block';
downloadContent.innerHTML = '';
return; return;
} }
const data = await response.json(); const data = await response.json();
if (data.error || !data.result || !data.result.data) { // Check for errors (400, 404, or error flag in response)
// Check if it's a 404 or file not found error if (data.error || !data.result || !data.result.data || response.status === 400 || response.status === 404) {
if (response.status === 404 || data.result?.comment?.includes('not found') || data.result?.comment?.includes('не найден')) { downloadStatus.textContent = 'Мы не смогли ничего найти.\nПерепроверьте введенный адрес.';
downloadStatus.textContent = 'Мы не смогли ничего найти. Перепроверьте введенный адрес.';
} else {
downloadStatus.textContent = 'Мы не смогли ничего найти. Перепроверьте введенный адрес.';
}
downloadStatus.className = 'status error'; downloadStatus.className = 'status error';
downloadStatus.style.display = 'block'; downloadStatus.style.display = 'block';
downloadContent.innerHTML = '';
return; return;
} }
@@ -102,7 +116,7 @@ async function handleDownloadPage(fileUuid) {
downloadStatus.style.display = 'none'; downloadStatus.style.display = 'none';
} catch (error) { } catch (error) {
// Network error or other connection issues // Network error or other connection issues
downloadStatus.textContent = 'Сервис временно недоступен, приносим наши извинения.'; downloadStatus.textContent = 'Сервис временно недоступен,\nприносим наши извинения.';
downloadStatus.className = 'status error'; downloadStatus.className = 'status error';
downloadStatus.style.display = 'block'; downloadStatus.style.display = 'block';
} }
+4
View File
@@ -164,6 +164,10 @@ button:disabled {
.status.error { .status.error {
color: #dc2626; color: #dc2626;
font-size: 18px;
font-weight: 500;
white-space: pre-line;
line-height: 1.6;
} }
.status.success { .status.success {