Update download.tsx

This commit is contained in:
Alexander-Ger-Reich
2025-12-11 23:17:33 +01:00
committed by GitHub
parent ade9ac863f
commit 0610f6fd1a

View File

@@ -113,7 +113,15 @@ export const DownloadImage = () => {
}
function handleFileChange(e: React.ChangeEvent<HTMLInputElement>) {
setSelectedFile(e.target.files?.[0] ?? null);
const file = e.target.files?.[0] ?? null;
if (!file || !file.name.toLowerCase().endsWith(".iso")) {
setStatus('failed');
setLog(t('download.NoISO'));
return;
}
setStatus('idle');
setLog('');
setSelectedFile(file);
clearInterval(intervalId.current);
intervalId.current = undefined;
}
@@ -121,6 +129,12 @@ export const DownloadImage = () => {
function upload(file: File | null) {
if (!file) return;
if (!file || !file.name.toLowerCase().endsWith(".iso")) {
setStatus('failed');
setLog(t('download.NoISO'));
return;
}
setStatus('in_progress');
setLog('Downloading: ' + file.name);
@@ -140,7 +154,6 @@ export const DownloadImage = () => {
setLog('');
});
console.log(intervalId.current);
// Start the interval to check the download status
if (!intervalId.current) {
getDownloadStatus();
@@ -200,6 +213,13 @@ export const DownloadImage = () => {
e.preventDefault();
setIsDragging(false);
const file = e.dataTransfer.files?.[0] ?? null;
if (!file || !file.name.toLowerCase().endsWith(".iso")) {
setStatus('failed');
setLog(t('download.NoISO'));
return;
}
setStatus('idle');
setLog('');
setSelectedFile(file);
}}
onDragOver={(e) => {