refactor: improve error handling and utility functions in bucket management components

Signed-off-by: Noooste <83548733+Noooste@users.noreply.github.com>
This commit is contained in:
Noooste
2026-04-19 22:37:55 +02:00
parent c5324db1ad
commit fece799627
4 changed files with 19 additions and 41 deletions
+7 -7
View File
@@ -90,10 +90,7 @@ export function useBucketObjects(bucketName: string | null, currentPath: string
setUploadTasks(tasks);
let successCount = 0;
let errorCount = 0;
for (const task of tasks) {
const results = await Promise.all(tasks.map(async (task) => {
try {
setUploadTasks(prev => prev.map(t =>
t.id === task.id ? { ...t, status: 'uploading' as const } : t
@@ -109,16 +106,19 @@ export function useBucketObjects(bucketName: string | null, currentPath: string
setUploadTasks(prev => prev.map(t =>
t.id === task.id ? { ...t, status: 'completed' as const, progress: 100 } : t
));
successCount++;
return true;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'Upload failed';
setUploadTasks(prev => prev.map(t =>
t.id === task.id ? { ...t, status: 'error' as const, error: errorMessage } : t
));
errorCount++;
console.error(`Failed to upload ${task.key}:`, error);
return false;
}
}
}));
const successCount = results.filter(Boolean).length;
const errorCount = results.length - successCount;
if (errorCount === 0) {
if (hasRelativePaths && folders.size > 0) {