From 48b087db917974796ef8a54be7c544dcbf0b7ea5 Mon Sep 17 00:00:00 2001 From: Ram Prasad Agarwal Date: Fri, 10 Jan 2025 21:10:22 +0530 Subject: [PATCH 1/3] [ui-storagebrowser] adds available space check in chunk upload (#3931) --- .../desktop/js/reactComponents/FileChooser/api.ts | 1 + .../utils/hooks/useFileUpload/useChunkUpload.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) 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) { From 95e4e0c37eae2362a3385f7f16917c11ec7fe29a Mon Sep 17 00:00:00 2001 From: Mahesh Balakrishnan Date: Fri, 10 Jan 2025 11:56:44 -0800 Subject: [PATCH 2/3] Fix JB Oozie Log Icon (#3952) Stacktrace seen: [07/Jan/2025 09:31:26 -0800] access ERROR admin - "POST /desktop/log_js_error HTTP/1.1" --- JS ERROR: {"msg":"Uncaught TypeError: lodash__WEBPACK_IMPORTED_MODULE_1___default.a.trimRight is not a function","url":"https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/hue-bundle-651ca10da11cbc8f75e8.2537e7eff7ba.js","line":74060,"column":139,"stack":"TypeError: lodash__WEBPACK_IMPORTED_MODULE_1___default.a.trimRight is not a function\n at app (https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/hue-bundle-651ca10da11cbc8f75e8.2537e7eff7ba.js:74060:139)\n at https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83803:52\n at nextEnter (https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83627:7)\n at https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83804:7\n at nextEnter (https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83627:7)\n at https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83804:7\n at nextEnter (https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83627:7)\n at https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83804:7\n at nextEnter (https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83627:7)\n at https://ccycloud-1.ni-717x-yq.root.comops.site:8889/static/desktop/js/bundles/hue/vendors~hue-chunk-651ca10da11cbc8f75e8.04f0b70fc23d.js:83804:7"} Co-authored-by: mbalakrishnan@cloudera.com --- desktop/core/src/desktop/templates/job_browser_common.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ - + From b4b4e0ee69318742d94f292bb33203c86156383e Mon Sep 17 00:00:00 2001 From: Harsh Gupta <42064744+Harshg999@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:08:04 +0530 Subject: [PATCH 3/3] [api] Remove unused compression field from /display API (#3955) --- apps/filebrowser/src/filebrowser/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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)