diff --git a/apps/filebrowser/src/filebrowser/api.py b/apps/filebrowser/src/filebrowser/api.py index 0e06cb00ef6..ebeb7bfa6f9 100644 --- a/apps/filebrowser/src/filebrowser/api.py +++ b/apps/filebrowser/src/filebrowser/api.py @@ -344,7 +344,7 @@ def display(request): return HttpResponse(f'Cannot request chunks greater than {MAX_CHUNK_SIZE_BYTES} bytes.', status=400) # Read out based on meta. - compression, offset, length, contents = read_contents(compression, path, request.fs, offset, length) + _, offset, length, contents = read_contents(compression, path, request.fs, offset, length) # Get contents as string for text mode, or at least try file_contents = None @@ -364,7 +364,6 @@ def display(request): 'length': length, 'end': offset + len(contents), 'mode': mode, - 'compression': compression, } return JsonResponse(data) diff --git a/desktop/core/src/desktop/js/reactComponents/FileChooser/api.ts b/desktop/core/src/desktop/js/reactComponents/FileChooser/api.ts index 00c2a3933a4..cbe0f7391d6 100644 --- a/desktop/core/src/desktop/js/reactComponents/FileChooser/api.ts +++ b/desktop/core/src/desktop/js/reactComponents/FileChooser/api.ts @@ -35,6 +35,7 @@ export const COPY_API_URL = '/api/v1/storage/copy/'; export const BULK_COPY_API_URL = '/api/v1/storage/copy/bulk/'; export const MOVE_API_URL = '/api/v1/storage/move/'; export const BULK_MOVE_API_URL = '/api/v1/storage/move/bulk/'; +export const UPLOAD_AVAILABLE_SPACE_URL = '/api/v1/taskserver/upload/available_space/'; export interface ApiFileSystem { file_system: string; diff --git a/desktop/core/src/desktop/js/utils/hooks/useFileUpload/useChunkUpload.ts b/desktop/core/src/desktop/js/utils/hooks/useFileUpload/useChunkUpload.ts index 23608fcb51f..fea271daa75 100644 --- a/desktop/core/src/desktop/js/utils/hooks/useFileUpload/useChunkUpload.ts +++ b/desktop/core/src/desktop/js/utils/hooks/useFileUpload/useChunkUpload.ts @@ -35,6 +35,8 @@ import { UploadChunkItem, UploadItem } from './util'; +import { get } from '../../../api/utils'; +import { UPLOAD_AVAILABLE_SPACE_URL } from '../../../reactComponents/FileChooser/api'; interface UseUploadQueueResponse { addFiles: (item: UploadItem[]) => void; @@ -134,7 +136,20 @@ const useChunkUpload = ({ }); }; + const checkAvailableSpace = async (fileSize: number) => { + const { upload_available_space: availableSpace } = await get<{ + upload_available_space: number; + }>(UPLOAD_AVAILABLE_SPACE_URL); + return availableSpace >= fileSize; + }; + const uploadItem = async (item: UploadItem) => { + const isSpaceAvailable = await checkAvailableSpace(item.file.size); + if (!isSpaceAvailable) { + onStatusUpdate(item, FileUploadStatus.Failed); + return Promise.resolve(); + } + onStatusUpdate(item, FileUploadStatus.Uploading); const chunks = getTotalChunk(item.file.size, chunkSize); if (chunks === 1) { diff --git a/desktop/core/src/desktop/templates/job_browser_common.mako b/desktop/core/src/desktop/templates/job_browser_common.mako index 9882a45e995..21ecc3f7cf0 100644 --- a/desktop/core/src/desktop/templates/job_browser_common.mako +++ b/desktop/core/src/desktop/templates/job_browser_common.mako @@ -2401,7 +2401,7 @@ - +