-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: thumbnail generator #8974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughWalkthroughThe recent updates introduce a comprehensive thumbnail generation feature for uploaded images, significantly enhancing image handling across various modules. Key modifications include the addition of parameters to functions for improved thumbnail management, refinements to the upload process, and the implementation of new job types and processors leveraging the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
participant JobsService
participant ThumbnailProcessor
User->>Frontend: Upload Image
Frontend->>Backend: Send Image Upload Request
Backend->>JobsService: Create Thumbnail Generation Job
JobsService->>ThumbnailProcessor: Process Thumbnail Job
ThumbnailProcessor->>Backend: Store Generated Thumbnails
Backend->>Frontend: Return Upload Results
Frontend->>User: Display Upload Confirmation
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
|
@coderabbitai review |
Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range and nitpick comments (1)
packages/nocodb/src/db/BaseModelSqlv2.ts (1)
Line range hint
7021-7035:
Add error handling for S3 thumbnail URL generation.The code for generating S3 thumbnail URLs does not handle potential errors from
PresignedUrl.getSignedUrl(). Consider adding error handling to ensure robustness.if (lookedUpAttachment.url.includes('.amazonaws.com/')) { try { let relativePath = decodeURI( lookedUpAttachment.url.split('.amazonaws.com/')[1], ); lookedUpAttachment.signedUrl = await PresignedUrl.getSignedUrl({ path: relativePath, s3: true, }); relativePath = relativePath.replace( 'nc/uploads/noco', 'nc/uploads/thumbnails', ); lookedUpAttachment.thumbnails = { tiny: {}, small: {}, card_cover: {}, }; lookedUpAttachment.thumbnails.tiny.signedUrl = await PresignedUrl.getSignedUrl({ path: `${relativePath}/tiny.jpg`, s3: true, }); lookedUpAttachment.thumbnails.small.signedUrl = await PresignedUrl.getSignedUrl({ path: `${relativePath}/small.jpg`, s3: true, }); lookedUpAttachment.thumbnails.card_cover.signedUrl = await PresignedUrl.getSignedUrl({ path: `${relativePath}/card_cover.jpg`, s3: true, }); } catch (error) { logger.error(`Error generating S3 thumbnail URLs: ${error.message}`); } }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (15)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (3 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (6 hunks)
- packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts (1 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts (1 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts (4 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (7 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (1 hunks)
Additional comments not posted (29)
packages/nc-gui/components/cell/attachment/Image.vue (1)
11-13: LGTM!The
onErrorfunction correctly updatesindex.valueusing Vue's reactivity system.packages/nc-gui/composables/useAttachment.ts (1)
4-9: LGTM!The changes to
getPossibleAttachmentSrccorrectly handle the optionalthumbnailparameter and update the logic to include thumbnails.packages/nocodb/src/interface/Jobs.ts (1)
20-20: LGTM!The additions to the
JobTypesenum and theThumbnailGeneratorJobDatainterface are correct and adhere to best practices.Also applies to: 125-128
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts (1)
22-22: LGTM!The import path for
AttachmentsServicehas been correctly updated.packages/nocodb/src/modules/jobs/jobs.module.ts (5)
3-4: Imports forMulterModuleandmulterlook correct.The imports are necessary for handling file uploads and are correctly added.
23-25: Imports forThumbnailGeneratorProcessor,AttachmentsSecureController, andAttachmentsControllerlook correct.These imports are necessary for handling thumbnail generation and secure attachment uploads.
38-38: Import forAttachmentsServicelooks correct.The import is necessary for handling attachment-related operations.
44-49:MulterModuleregistration looks correct.The
MulterModuleis registered with appropriate configurations for storage and limits.
Line range hint
87-100:
Additions ofAttachmentsServiceandThumbnailGeneratorProcessorlook correct.These additions are necessary for handling attachment-related operations and thumbnail generation.
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts (1)
21-21: Import forAttachmentsServicelooks correct.The import is necessary for handling attachment-related operations.
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (7)
1-13: Imports forAttachmentsService,sharp,axios, and other dependencies look correct.These imports are necessary for handling thumbnail generation and related operations.
15-17:ThumbnailGeneratorProcessorclass definition and constructor look correct.The class is correctly defined to process thumbnail generation jobs, with the
AttachmentsServicecorrectly initialized in the constructor.
21-34:jobmethod implementation looks correct.The method correctly processes jobs to generate thumbnails for image attachments and handles errors appropriately.
36-144:generateThumbnailmethod implementation looks correct.The method correctly generates thumbnails for image attachments using
sharpand handles various scenarios for obtaining the file.
139-143: Logging and error handling ingenerateThumbnailmethod look correct.The logging and error handling are correctly implemented and provide useful information during failures.
122-127: Usage ofsharpfor image processing looks correct.The usage of
sharpis correctly implemented and optimized for resizing images to generate thumbnails.
62-63: Usage ofaxiosfor fetching files looks correct.The usage of
axiosis correctly implemented and handles errors appropriately.packages/nocodb/src/plugins/s3/S3.ts (1)
78-83:fileCreateByStreammethod implementation looks correct.The method correctly handles file creation by stream asynchronously using promises and handles errors appropriately.
packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3)
13-13: New Import: ThumbnailGeneratorProcessorThe
ThumbnailGeneratorProcessorclass is imported to handle thumbnail generation jobs.
39-39: New Processor: ThumbnailGeneratorProcessorThe
ThumbnailGeneratorProcessoris added as a protected member of theQueueServiceclass.
105-108: New Job Type: ThumbnailGeneratorA new job type
ThumbnailGeneratoris added to the job map, linking it to thethumbnailGeneratorProcessor.packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts (4)
18-20: New Imports: Job-related services and typesThe
IJobsService,JobTypes, andRootScopesare imported to facilitate job handling.
26-30: Updated Constructor: Added jobsServiceThe constructor now includes an additional
jobsServiceparameter, injected usingforwardRefto avoid circular dependencies.
123-131: New Job Addition: ThumbnailGenerator in upload methodA new job of type
ThumbnailGeneratoris added to the jobs service within theuploadmethod to handle thumbnail generation for uploaded files.
213-221: New Job Addition: ThumbnailGenerator in uploadViaURL methodA new job of type
ThumbnailGeneratoris added to the jobs service within theuploadViaURLmethod to handle thumbnail generation for files uploaded via URL.packages/nocodb/src/modules/noco.module.ts (1)
121-121: Simplified Module Metadata: Removed multer and MulterModuleThe references to
multerandMulterModuleare removed, simplifying the module metadata.packages/nc-gui/components/cell/attachment/index.vue (1)
303-303: Modified Function Call: getPossibleAttachmentSrcThe
getPossibleAttachmentSrcfunction call is modified to include an additional argument for handling different image sizes ('card_cover'and'tiny').packages/nc-gui/components/smartsheet/Gallery.vue (1)
307-307: LGTM! The change to include 'card_cover' looks good.The addition of the
'card_cover'argument togetPossibleAttachmentSrcis consistent with the PR's objective to handle different image sizes.packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts (1)
21-21: Verify the necessity and correctness of theAttachmentsServiceimport.Ensure that
AttachmentsServicefrom thethumbnail-generatormodule is correctly used within the file. If it is not used, consider removing the import to avoid unnecessary dependencies.
1fb39eb to
ded0520
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (25)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (6 hunks)
- packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts (4 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (7 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (1 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (1 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (1 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (1 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (1 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (1 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (1 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (1 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- packages/nocodb/.gitignore
- packages/nocodb/src/interface/Jobs.ts
Files skipped from review as they are similar to previous changes (12)
- packages/nc-gui/components/cell/attachment/Image.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/s3/S3.ts
Additional comments not posted (5)
packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (1)
81-99: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<any>, which is consistent with the resolved value. The method looks good overall.packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (1)
131-149: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<any>, which is consistent with the resolved value. The method looks good overall.packages/nocodb/src/plugins/mino/Minio.ts (1)
138-141: Verify if the metadata object should be populated.The metadata object is currently empty. Confirm if this is intentional or if it should contain specific metadata.
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts (2)
21-21: New Import: AttachmentsServiceThe
AttachmentsServicehas been imported. Ensure that it is used correctly in the code.Verification successful
Verified Import Usage: AttachmentsService
The
AttachmentsServiceimport inpackages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.tsis correctly utilized within the file.
- The
attachmentsServiceis instantiated and used in the file, confirming the necessity of the import.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `AttachmentsService` in the file. # Test: Search for the usage of `AttachmentsService`. Expect: Occurrences of `attachmentsService`. rg --type ts 'attachmentsService'Length of output: 2745
Ensure Proper Error Handling for Attachment Uploads
The
attachmentsService.uploadViaURLmethod is used to upload attachments in the following files:
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.tspackages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.tspackages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.tsCurrently, these calls are not wrapped in
try-catchblocks or any other error handling mechanisms. It is recommended to implement proper error handling to avoid potential issues during the upload process.
- Wrap
attachmentsService.uploadViaURLcalls intry-catchblocks or implement other appropriate error handling mechanisms.Analysis chain
Line range hint
565-577:
Ensure Proper Error Handling for Attachment UploadsThe
attachmentsService.uploadViaURLmethod is used to upload attachments. Ensure that errors are handled appropriately to avoid potential issues during the upload process.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the error handling for `attachmentsService.uploadViaURL`. # Test: Search for error handling code around `attachmentsService.uploadViaURL`. Expect: Proper error handling mechanisms. rg --type ts -A 5 'attachmentsService.uploadViaURL'Length of output: 2072
Script:
#!/bin/bash # Description: Verify the error handling for `attachmentsService.uploadViaURL` in the identified files. # Search for `try-catch` blocks around `attachmentsService.uploadViaURL` in `attachments.controller.ts` rg --type ts -A 10 'try' packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts # Search for `try-catch` blocks around `attachmentsService.uploadViaURL` in `attachments-secure.controller.ts` rg --type ts -A 10 'try' packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts # Search for `try-catch` blocks around `attachmentsService.uploadViaURL` in `at-import.processor.ts` rg --type ts -A 10 'try' packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.tsLength of output: 6067
Script:
#!/bin/bash # Description: Verify the error handling for `attachmentsService.uploadViaURL` in the identified files. # Check if `attachmentsService.uploadViaURL` is inside a try-catch block in `attachments.controller.ts` rg --type ts -A 5 -B 5 'attachmentsService.uploadViaURL' packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts # Check if `attachmentsService.uploadViaURL` is inside a try-catch block in `attachments-secure.controller.ts` rg --type ts -A 5 -B 5 'attachmentsService.uploadViaURL' packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts # Check if `attachmentsService.uploadViaURL` is inside a try-catch block in `at-import.processor.ts` rg --type ts -A 5 -B 5 'attachmentsService.uploadViaURL' packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.tsLength of output: 1446
ded0520 to
e4c5107
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (25)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (6 hunks)
- packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts (4 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (7 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (1 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (1 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (1 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (1 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (1 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (1 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (1 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (1 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/nocodb/src/plugins/spaces/Spaces.ts
Files skipped from review as they are similar to previous changes (20)
- packages/nc-gui/components/cell/attachment/Image.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nocodb/.gitignore
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/plugins/backblaze/Backblaze.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/s3/S3.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts
- packages/nocodb/src/plugins/vultr/Vultr.ts
Additional comments not posted (8)
packages/nc-gui/composables/useAttachment.ts (3)
4-9: Add comments for clarity and verify nested function call.The
getPossibleAttachmentSrcfunction now handles different thumbnail sizes, which is a good enhancement. However, adding comments to explain the logic would improve readability. Also, verify that the nested call togetPossibleAttachmentSrcdoes not lead to infinite recursion.[nitpick, verify]
const getPossibleAttachmentSrc = (item: Record<string, any>, thumbnail?: 'card_cover' | 'tiny' | 'small') => { + // Initialize an empty array to store possible attachment sources const res: string[] = [] if (thumbnail && item?.thumbnails && item.thumbnails[thumbnail]) { + // Add the thumbnail source to the result array res.push(getPossibleAttachmentSrc(item.thumbnails[thumbnail])[0]) } if (item?.data) res.push(item.data) if (item?.file) res.push(window.URL.createObjectURL(item.file)) if (item?.signedPath) res.push(`${appInfo.value.ncSiteUrl}/${encodeURI(item.signedPath)}`) if (item?.signedUrl) res.push(item.signedUrl) if (item?.path) res.push(`${appInfo.value.ncSiteUrl}/${encodeURI(item.path)}`) if (item?.url) res.push(item.url) return res }
Line range hint
11-23: LGTM!The
getAttachmentSrcfunction handles errors gracefully and returns the first accessible source.
Line range hint
25-27: LGTM!The
openAttachmentfunction is straightforward and correct.packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3)
81-102: RefactorfileCreateByStreammethod and add error handling.The method can be simplified by removing the unnecessary promise wrapper and adding error handling for stream errors.
[refactor_suggestion, duplicate_comment]async fileCreateByStream(key: string, stream: Readable): Promise<void> { const uploadParams: any = { ACL: 'public-read', Body: stream, Key: key, }; try { stream.on('error', (err) => { console.log('Stream Error', err); throw err; }); const data = await this.s3Client.upload(uploadParams).promise(); return data.Location; } catch (err) { console.log('Error', err); throw err; } }
Line range hint
104-106: Skip placeholder functionfileReadByStream.The function is not implemented yet.
Line range hint
108-110: Skip placeholder functiongetDirectoryList.The function is not implemented yet.
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts (1)
Line range hint
223-235: LGTM!The
getFilefunction is straightforward and correct.packages/nocodb/src/modules/noco.module.ts (1)
4-5: LGTM!The changes in the module metadata are correct and necessary for the new thumbnail generation functionality.
Also applies to: 121-126
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts
Show resolved
Hide resolved
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts
Show resolved
Hide resolved
e4c5107 to
15e8f96
Compare
396b1be to
522cd39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
Outside diff range, codebase verification and nitpick comments (1)
packages/nocodb/src/modules/noco.module.ts (1)
121-121: Removed attachment size constant import.The import of
NC_ATTACHMENT_FIELD_SIZEwas removed frompackages/nocodb/src/modules/noco.module.ts, but the constant is still being used in the codebase. Please ensure that the import is restored or the usage of the constant is updated accordingly.
packages/nocodb/src/modules/noco.module.tspackages/nocodb/src/modules/jobs/jobs.module.tspackages/nocodb/src/services/utils.service.tsAnalysis chain
Removed attachment size constant import.
The removal of
NC_ATTACHMENT_FIELD_SIZEimport needs verification to ensure that the constant is no longer used or has been relocated.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of NC_ATTACHMENT_FIELD_SIZE in the codebase. # Test: Search for the usage of NC_ATTACHMENT_FIELD_SIZE. rg --type python -A 5 $'NC_ATTACHMENT_FIELD_SIZE'Length of output: 79
Script:
#!/bin/bash # Description: Verify the usage of NC_ATTACHMENT_FIELD_SIZE in the codebase. # Test: Search for the usage of NC_ATTACHMENT_FIELD_SIZE in TypeScript and JavaScript files. rg 'NC_ATTACHMENT_FIELD_SIZE' --type js --type ts -A 5Length of output: 3185
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (31)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (3 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (6 hunks)
- packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts (5 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts (9 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (7 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (2 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (2 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (2 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (2 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (2 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (1 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (2 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (2 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (2 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (2 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (18)
- packages/nc-gui/components/cell/attachment/Image.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments-secure.controller.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/plugins/backblaze/Backblaze.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 77-77: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (14)
packages/nocodb/src/plugins/vultr/Vultr.ts (1)
84-102: Refactor offileCreateByStreamto use async/await.The method has been refactored to use async/await, which improves readability and error handling. However, the previous comment about ensuring proper error handling and return type consistency still applies.
packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (1)
84-101: UpdatedfileCreateByStreamwith async/await and improved error handling.The method now uses async/await, which simplifies the handling of asynchronous operations. The change should improve the reliability and readability of the code.
However, ensure that the error handling is robust enough to manage potential issues with network or S3 operations.
Verification successful
Updated
fileCreateByStreamwith async/await and improved error handling.The method now uses async/await, which simplifies the handling of asynchronous operations. The change should improve the reliability and readability of the code. However, ensure that the error handling is robust enough to manage potential issues with network or S3 operations.
- LinodeObjectStorage.ts: Uses a promise with
resolveandrejectinside thes3Client.uploadcallback.- S3.ts: Uses a promise with
resolveandrejectinside thethis.uploadmethod.- Minio.ts: Uses a promise with
resolveandrejectinside the upload logic.The error handling in
LinodeObjectStorage.tsappears consistent with other similar implementations.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify error handling in fileCreateByStream method across similar implementations in the codebase. rg --type python -A 5 $'fileCreateByStream'Length of output: 73
Script:
#!/bin/bash # Description: Verify error handling in fileCreateByStream method across similar implementations in the codebase. rg --type typescript -A 5 $'fileCreateByStream'Length of output: 81
Script:
#!/bin/bash # Description: Verify error handling in fileCreateByStream method across similar implementations in the codebase. rg -A 5 $'fileCreateByStream'Length of output: 9834
packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
84-105: Optimization and error handling infileCreateByStream.The method has been optimized to use async/await, enhancing the handling of asynchronous operations and simplifying the code. The previous comments about optimizing the method and adding error handling are still relevant.
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts (1)
22-22: Updated import path for AttachmentsServiceThe import path for
AttachmentsServicehas been updated to reflect its new location. This is a straightforward change, but it's crucial to ensure that all references to this service within the file are updated accordingly.packages/nocodb/src/plugins/s3/S3.ts (1)
81-86: Refactor of fileCreateByStream using async/awaitThe method
fileCreateByStreamhas been refactored to use async/await for better readability and error handling. This change should help in managing asynchronous operations more effectively.However, ensure that the error handling is robust and that all possible errors are appropriately caught and handled.
Verification successful
Refactor of fileCreateByStream using async/await
The method
fileCreateByStreamhas been refactored to use async/await for better readability and error handling. This change should help in managing asynchronous operations more effectively.
- The method correctly handles errors by rejecting the promise in case of an error during the upload process.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify error handling in fileCreateByStream method. # Test: Search for error handling patterns. Expect: Robust error handling. rg --type typescript -A 5 $'fileCreateByStream'Length of output: 81
Script:
#!/bin/bash # Description: Verify error handling in fileCreateByStream method. # Test: Search for error handling patterns. Expect: Robust error handling. rg 'fileCreateByStream' -A 10 --glob '*.ts'Length of output: 17730
packages/nc-gui/components/cell/attachment/Modal.vue (1)
149-149: Updated argument in getPossibleAttachmentSrc callThe
getPossibleAttachmentSrcfunction now receives an additional argument'card_cover'which likely affects how thumbnails are generated for attachments. This change should be tested thoroughly to ensure it integrates seamlessly with the existing functionality.Verification successful
Updated argument in getPossibleAttachmentSrc call
The
getPossibleAttachmentSrcfunction now consistently receives an additional argument (e.g., 'card_cover', 'tiny') across multiple files in the codebase. This indicates that the change is well-integrated and should not introduce any issues.
- Verified consistent usage in:
packages/nc-gui/components/smartsheet/Form.vuepackages/nc-gui/components/smartsheet/calendar/SideMenu.vuepackages/nc-gui/components/virtual-cell/components/ListItem.vuepackages/nc-gui/components/smartsheet/Kanban.vuepackages/nc-gui/components/smartsheet/Gallery.vuepackages/nc-gui/components/general/FormBanner.vuepackages/nc-gui/components/cell/attachment/Carousel.vuepackages/nc-gui/components/cell/attachment/index.vuepackages/nc-gui/components/cell/attachment/Modal.vueScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of getPossibleAttachmentSrc with new argument. # Test: Search for usage of getPossibleAttachmentSrc in the project. Expect: Consistent usage of new argument. rg --type vue -A 5 $'getPossibleAttachmentSrc'Length of output: 73
Script:
#!/bin/bash # Description: Verify integration of getPossibleAttachmentSrc with new argument. # Test: Search for usage of getPossibleAttachmentSrc in the project. Expect: Consistent usage of new argument. rg getPossibleAttachmentSrc -A 5Length of output: 11526
packages/nc-gui/components/virtual-cell/components/ListItem.vue (1)
95-95: Updated argument in getPossibleAttachmentSrc call in ListItem.vueThe
getPossibleAttachmentSrcfunction now receives an additional argument'tiny'which likely affects how thumbnails are generated for list items. This change should be tested thoroughly to ensure it integrates seamlessly with the existing functionality.Verification successful
Updated argument in getPossibleAttachmentSrc call in ListItem.vue
The
getPossibleAttachmentSrcfunction now receives an additional argument'tiny', which likely affects how thumbnails are generated for list items. This change is consistent with other usages in the codebase and should integrate seamlessly with the existing functionality.
packages/nc-gui/components/virtual-cell/components/ListItem.vue: Line 95Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of getPossibleAttachmentSrc with new argument in ListItem.vue. # Test: Search for usage of getPossibleAttachmentSrc in the project. Expect: Consistent usage of new argument. rg --type vue -A 5 $'getPossibleAttachmentSrc'Length of output: 73
Script:
#!/bin/bash # Description: Verify integration of getPossibleAttachmentSrc with new argument in ListItem.vue. # Test: Search for usage of getPossibleAttachmentSrc in the project. Expect: Consistent usage of new argument. rg -A 5 'getPossibleAttachmentSrc'Length of output: 11526
packages/nocodb/src/modules/noco.module.ts (2)
Line range hint
121-148: Significant changes in module metadata.The module metadata has been significantly refactored:
- Removed
MulterModuleconfiguration.- Adjusted controller imports based on environment variables.
These changes align with the removal of direct file handling in this module. Ensure that the conditional logic for controller imports is correctly implemented and tested.
4-5: Removed Multer and related imports.The removal of
MulterModuleandmultersuggests a refactoring or relocation of file handling logic. Ensure that this change is consistent with the new architecture for handling uploads and image processing as described in the PR summary.packages/nocodb/src/services/public-datas.service.ts (3)
2-2: Added imports for image processing and job handling.The addition of
sharpfor image processing andIJobsServicefor job handling are crucial for the new thumbnail generation feature. Ensure that these imports are used appropriately within the service.Also applies to: 8-8, 22-24
Verification successful
Verified imports for image processing and job handling.
The imports of
sharpfor image processing andIJobsServicefor job handling are correctly utilized within thepublic-datas.service.tsfile.
sharpis used for handling image metadata.IJobsServiceis injected and used for job handling.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of sharp and IJobsService in the service. # Test: Search for the usage of sharp and IJobsService. rg --type python -A 5 $'sharp|IJobsService'Length of output: 75
Script:
#!/bin/bash # Description: Verify the usage of sharp and IJobsService in the service. # Test: Search for the usage of sharp and IJobsService within TypeScript files. rg --type ts -A 5 'sharp|IJobsService'Length of output: 19333
Line range hint
417-456: Thumbnail generation logic for image uploads.The logic for generating thumbnails during the file upload process has been implemented. This includes extracting image dimensions using
sharpand adding these dimensions to the metadata. Ensure that the error handling and performance implications of this logic are considered.Also applies to: 491-534
Verification successful
Verification successful for error handling and performance considerations in thumbnail generation logic.
The code includes appropriate
catchblocks to handle errors during image processing and usesawaitfor asynchronous operations to manage performance implications effectively.
- Error Handling: Errors are caught and either logged or ignored, which is suitable for the context.
- Performance: Asynchronous operations with
awaitensure non-blocking execution.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the error handling and performance of thumbnail generation logic. # Test: Search for error handling related to thumbnail generation. rg --type python -A 5 $'catch'Length of output: 60
Script:
#!/bin/bash # Description: Verify the error handling and performance of thumbnail generation logic. # Test: Search for error handling related to thumbnail generation in the TypeScript file. rg --type ts -A 5 'catch' packages/nocodb/src/services/public-datas.service.ts # Test: Search for performance-related code (e.g., await) in the TypeScript file. rg --type ts -A 5 'await' packages/nocodb/src/services/public-datas.service.tsLength of output: 12855
33-36: Constructor added for JobsService injection.The constructor for
JobsServiceinjection is necessary for handling thumbnail generation jobs. Ensure that theJobsServiceis correctly configured and used within the service.Verification successful
JobsService is correctly configured and used.
The
JobsServiceis consistently imported, injected, and utilized across multiple files in the codebase. This confirms that the constructor addition forJobsServiceinjection is appropriate and necessary.
packages/nocodb/src/services/hook-handler.service.tspackages/nocodb/src/services/public-datas.service.tspackages/nocodb/src/modules/jobs/jobs.controller.tspackages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.tspackages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.tspackages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.tspackages/nocodb/src/modules/jobs/jobs.module.tspackages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.tspackages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.service.tspackages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.tspackages/nocodb/src/modules/jobs/jobs/data-export/data-export.controller.tspackages/nocodb/src/modules/jobs/redis/jobs.service.tspackages/nocodb/src/modules/jobs/fallback/jobs.service.tsScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the configuration and usage of JobsService. # Test: Search for the configuration and usage of JobsService. rg --type python -A 5 $'JobsService'Length of output: 66
Script:
#!/bin/bash # Description: Verify the configuration and usage of JobsService. # Test: Search for the configuration and usage of JobsService in TypeScript files. rg --type typescript -A 5 'JobsService'Length of output: 74
Script:
#!/bin/bash # Description: Verify the configuration and usage of JobsService. # Test: Search for the configuration and usage of JobsService in TypeScript files. rg --type ts -A 5 'JobsService'Length of output: 16780
packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1)
589-589: EnhancedgetPossibleAttachmentSrcfunction to handle 'tiny' thumbnails.The addition of the
'tiny'argument allows for handling different thumbnail sizes, aligning with the new thumbnail generation feature. Ensure that this change is reflected across all relevant parts of the application where thumbnails are used.Verification successful
Enhanced
getPossibleAttachmentSrcfunction to handle 'tiny' thumbnails.The addition of the
'tiny'argument allows for handling different thumbnail sizes, aligning with the new thumbnail generation feature. This change is reflected across various parts of the application where thumbnails are used.
packages/nc-gui/components/smartsheet/calendar/SideMenu.vuepackages/nc-gui/components/virtual-cell/components/ListItem.vuepackages/nc-gui/composables/useAttachment.tsScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of 'tiny' argument across the application. # Test: Search for the usage of 'tiny' argument. rg --type python -A 5 $'tiny'Length of output: 59
Script:
#!/bin/bash # Description: Verify the usage of 'tiny' argument across the application. # Test: Search for the usage of 'tiny' argument in Vue and JavaScript files. rg --type vue --type js -A 5 'tiny'Length of output: 63
Script:
#!/bin/bash # Description: Verify the usage of 'tiny' argument across the application. # Test: Search for the usage of 'tiny' argument in all files. rg -A 5 'tiny'Length of output: 160105
packages/nc-gui/components/smartsheet/Kanban.vue (1)
793-793: Check integration of thumbnail generator featureThe change to include an additional argument
'card_cover'in thegetPossibleAttachmentSrcfunction call is directly related to the new thumbnail generator feature. This is a key part of the PR's objectives.Ensure that this change does not unintentionally affect other areas where
getPossibleAttachmentSrcis used. It would be beneficial to verify that all usages of this function have been appropriately updated or guarded against potential side effects.Verification successful
Check integration of thumbnail generator feature
The change to include an additional argument
'card_cover'in thegetPossibleAttachmentSrcfunction call is correctly integrated. The function is used across multiple files, and the instances where it is called with thethumbnailargument ('card_cover','tiny','small') are appropriately handled.
packages/nc-gui/components/smartsheet/Kanban.vuepackages/nc-gui/components/virtual-cell/components/ListItem.vuepackages/nc-gui/components/smartsheet/Gallery.vuepackages/nc-gui/components/smartsheet/calendar/SideMenu.vuepackages/nc-gui/components/cell/attachment/Modal.vuepackages/nc-gui/components/cell/attachment/index.vueThe integration aligns with the PR's objectives and does not introduce unintended side effects.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `getPossibleAttachmentSrc` to ensure they handle the new argument correctly. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type vue -A 5 $'getPossibleAttachmentSrc'Length of output: 73
Script:
#!/bin/bash # Description: Verify all function calls to `getPossibleAttachmentSrc` to ensure they handle the new argument correctly. # Test: Search for the function usage in all files. rg -A 5 $'getPossibleAttachmentSrc'Length of output: 11526
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/attachments.controller.ts
Show resolved
Hide resolved
522cd39 to
d66af97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (1)
packages/nocodb/src/services/attachments.service.ts (1)
Line range hint
60-154: Assess the logic and security implications of image metadata extraction and thumbnail generation.The method
uploadnow handles image metadata extraction and thumbnail generation. Ensure that the image processing logic is secure and does not introduce any vulnerabilities. Additionally, the use of asynchronous job creation for thumbnail generation should be verified to ensure it does not impact system performance or stability.- const metadata = await sharp(file.path, { + const metadata = await sharp(file.path).metadata(); - }).metadata(); + // Ensure that error handling is robust to handle potential image processing failures
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (30)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (3 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (10 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (2 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (2 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (2 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (2 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (2 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (1 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (2 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (2 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (2 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (2 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (27)
- packages/nc-gui/components/cell/attachment/Image.vue
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/backblaze/Backblaze.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts
- packages/nocodb/src/plugins/s3/S3.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/plugins/storage/Local.ts
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts
- packages/nocodb/src/plugins/vultr/Vultr.ts
- packages/nocodb/src/services/public-datas.service.ts
Additional comments not posted (1)
packages/nocodb/src/services/attachments.service.ts (1)
9-9: Verify the use ofsharpfor image processing.The use of
sharpfor image processing is generally safe and efficient. However, ensure that the image data handled bysharpis sanitized and validated to prevent potential security vulnerabilities such as image payload attacks.
d66af97 to
e009297
Compare
33e5ce8 to
a50de3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
Outside diff range, codebase verification and nitpick comments (4)
packages/nocodb/src/plugins/gcs/Gcs.ts (2)
Line range hint
121-129:
Improve error handling in thefileCreateByUrlmethod.Include more context in the error message to provide better insights during debugging.
- .catch((error) => { - reject(error); - }); + .catch((error) => { + reject(new Error(`Failed to upload file from URL: ${url}. Error: ${error.message}`)); + });
Line range hint
90-100:
Improve error handling in thefileReadmethod.Include more context in the error message to provide better insights during debugging.
- file.exists((err, exists) => { - if (exists) { - file.download((downerr, data) => { - if (err) { - return reject(downerr); - } - return resolve(data); - }); - } else { - reject(err); - } - }); + file.exists((err, exists) => { + if (err) { + return reject(new Error(`Failed to check existence of file: ${key}. Error: ${err.message}`)); + } + if (exists) { + file.download((downerr, data) => { + if (downerr) { + return reject(new Error(`Failed to download file: ${key}. Error: ${downerr.message}`)); + } + return resolve(data); + }); + } else { + reject(new Error(`File does not exist: ${key}`)); + } + });packages/nocodb/src/plugins/s3/S3.ts (2)
Line range hint
63-83:
Improve error handling in thefileCreateByStreammethod.Include more context in the error message to provide better insights during debugging.
- .catch((err) => { - reject(err); - }); + .catch((err) => { + reject(new Error(`Failed to upload file to path: ${key}. Error: ${err.message}`)); + });Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Line range hint
113-123:
Improve error handling in thefileReadmethod.Include more context in the error message to provide better insights during debugging.
- this.s3Client.getObject({ Key: key } as any, (err, data) => { - if (err) { - return reject(err); - } - if (!data?.Body) { - return reject(data); - } - return resolve(data.Body); - }); + this.s3Client.getObject({ Key: key } as any, (err, data) => { + if (err) { + return reject(new Error(`Failed to read file: ${key}. Error: ${err.message}`)); + } + if (!data?.Body) { + return reject(new Error(`File has no body: ${key}`)); + } + return resolve(data.Body); + });
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (30)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review due to trivial changes (1)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
Files skipped from review as they are similar to previous changes (18)
- packages/nc-gui/components/cell/attachment/Image.vue
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/controllers/attachments.controller.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/plugins/storage/Local.ts
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (19)
packages/nc-gui/composables/useAttachment.ts (2)
4-9: LGTM! Ensure the new parameter is handled correctly.The changes to handle the
thumbnailparameter are correct. Ensure that the new parameter is used correctly in all function calls.
4-9: Verify the correctness of the recursive call.The recursive call to
getPossibleAttachmentSrcshould correctly handle thethumbnailparameter to avoid infinite recursion or incorrect results.Verification successful
The recursive call in
getPossibleAttachmentSrcis correctly implemented.The function correctly handles the
thumbnailparameter and prevents infinite recursion by not passing thethumbnailparameter in the recursive call.
- The recursive call
getPossibleAttachmentSrc(item.thumbnails[thumbnail])[0]is correctly implemented.- The function usage without the
thumbnailparameter is consistent with the intended functionality.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the recursive call in `getPossibleAttachmentSrc`. # Test: Search for the function usage to ensure it handles the `thumbnail` parameter correctly. rg --type typescript -A 5 $'getPossibleAttachmentSrc'Length of output: 87
Script:
#!/bin/bash # Description: Verify the correctness of the recursive call in `getPossibleAttachmentSrc`. # Test: Search for the function usage to ensure it handles the `thumbnail` parameter correctly. rg --glob '*.ts' -A 5 'getPossibleAttachmentSrc'Length of output: 1907
packages/nocodb/src/plugins/vultr/Vultr.ts (1)
19-22: LGTM! Verify the function usage.The changes streamline the file creation process by delegating the upload logic to the
fileCreateByStreammethod.Ensure that the function calls to
fileCreatehandle the changes correctly.Verification successful
LGTM! Verify the function usage.
The changes streamline the file creation process by delegating the upload logic to the
fileCreateByStreammethod. The function calls tofileCreatehandle the changes correctly.
- Instances of
fileCreatein multiple files show consistent usage with the new implementation.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the function calls to `fileCreate` handle the changes correctly. # Test: Search for the function usage to ensure it handles the changes correctly. rg --type typescript -A 5 $'fileCreate'Length of output: 73
Script:
#!/bin/bash # Description: Verify the function calls to `fileCreate` handle the changes correctly. # Test: Search for the function usage to ensure it handles the changes correctly. rg --type ts -A 5 $'fileCreate'Length of output: 28646
packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (1)
19-22: LGTM! Verify the function usage.The changes improve code clarity by separating concerns and enhancing the file creation process.
Ensure that the function calls to
fileCreatehandle the changes correctly.Verification successful
Let's re-run the verification by first finding all TypeScript files and then searching for
fileCreatewithin those files.
LGTM! Verify the function usage.
The changes improve code clarity by separating concerns and enhancing the file creation process. The function calls to
fileCreateappear to handle the changes correctly based on the search results.
- Ensure that the function calls to
fileCreatehandle the changes correctly in the following files:
packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts- Other files where
fileCreateis used.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the function calls to `fileCreate` handle the changes correctly. # Test: Search for the function usage to ensure it handles the changes correctly. rg --type typescript -A 5 $'fileCreate'Length of output: 73
Script:
#!/bin/bash # Description: Verify the function calls to `fileCreate` handle the changes correctly. # Find all TypeScript files and search for the function usage to ensure it handles the changes correctly. fd -e ts -e tsx -x rg 'fileCreate' {}Length of output: 3584
packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
19-22: LGTM! The changes improve separation of concerns.The
fileCreatemethod now correctly delegates stream handling tofileCreateByStream.packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! The changes improve separation of concerns.The
fileCreatemethod now correctly delegates stream handling tofileCreateByStream.packages/nocodb/src/plugins/mino/Minio.ts (1)
19-21: LGTM! The changes improve separation of concerns.The
fileCreatemethod now correctly delegates stream handling tofileCreateByStream.packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1)
18-22: LGTM!The constructor and logger initialization are straightforward and correct.
packages/nocodb/src/plugins/gcs/Gcs.ts (1)
Line range hint
24-32:
LGTM!The
fileCreatemethod is well-structured and follows best practices for uploading files to Google Cloud Storage.packages/nocodb/src/plugins/s3/S3.ts (2)
31-34: LGTM!The
fileCreatemethod is well-structured and follows best practices for uploading files to AWS S3.
Line range hint
164-181:
LGTM!The
uploadmethod is well-structured and follows best practices for uploading files to AWS S3.packages/nocodb/src/services/public-datas.service.ts (5)
2-2: LGTM! New imports are appropriate.The new imports are necessary for the added functionality, including dependency injection and image processing.
Also applies to: 8-8, 22-24
33-36: LGTM! Constructor for injecting JobsService is well-implemented.The constructor uses
forwardRefto avoid circular dependencies and correctly injectsJobsService.
417-432: Extracting image metadata is well-implemented.The code correctly extracts image metadata (width and height) using
sharpfor files with image MIME types.
491-513: Extracting image metadata from URL is well-implemented.The code correctly extracts image metadata (width and height) using
sharpfor images uploaded by URL.
542-548: Adding thumbnail generation job is well-implemented.The code correctly adds a job to generate thumbnails using
JobsService.packages/nocodb/src/db/BaseModelSqlv2.ts (3)
7209-7213: Optimize thumbnail path handling in lookedUpAttachmentThe code for handling thumbnail paths in the
lookedUpAttachmentobject can be optimized. Currently, the relative path is recalculated multiple times which is inefficient.- let relativePath = lookedUpAttachment.path.replace(/^download\//, ''); + let basePath = lookedUpAttachment.path.replace(/^download\//, ''); + let relativePath = `thumbnails/${basePath}`;
7308-7309: Optimize thumbnail path handling for single attachmentsThe code for handling thumbnail paths for single attachments can be optimized to avoid redundant string operations.
- let relativePath = attachment.path.replace(/^download\//, ''); + let basePath = attachment.path.replace(/^download\//, ''); + let relativePath = `thumbnails/${basePath}`;
8520-8521: Ensure width and height properties are handled properlyThe code now includes handling for
widthandheightproperties for attachments. Ensure that these properties are correctly populated and validated.Verification successful
Ensure width and height properties are handled properly
The
widthandheightproperties for attachments are being properly handled and validated in the codebase. Key locations include:
packages/nocodb/src/services/attachments.service.tspackages/nocodb/src/services/public-datas.service.tspackages/nocodb/src/db/BaseModelSqlv2.tsThese files contain logic to populate and validate these properties, ensuring they are correctly managed.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that width and height properties are handled properly in attachments. # Test: Search for the usage of width and height properties in the codebase. Expect: Proper handling and validation. rg --type typescript -A 5 $'width|height'Length of output: 77
Script:
#!/bin/bash # Description: Verify that width and height properties are handled properly in attachments. # Test: Search for the usage of width and height properties in the codebase. Expect: Proper handling and validation. rg --type ts -A 5 'width|height'Length of output: 170848
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
Show resolved
Hide resolved
a50de3f to
f05344a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (30)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (19)
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments.controller.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (23)
packages/nc-gui/components/cell/attachment/Image.vue (3)
11-13: LGTM! The explicit increment operation improves clarity.The change from
index.value++toindex.value = index.value + 1enhances readability.
17-19: Reminder: Fix the issue with<LazyNuxtImg>.The TODO comment indicates that the issue with
<LazyNuxtImg>needs to be fixed.
20-26: LGTM! The changes to the<img>element improve robustness.Replacing
<LazyNuxtImg>with<img>and adding@error="onError"enhances error handling. The use ofprops.srcs?.lengthensures robustness against undefined properties.packages/nocodb/src/controllers/attachments-secure.controller.ts (2)
2-2: Verify the use offs.existsSyncfor potential blocking I/O operations.The use of
fs.existsSyncmight introduce blocking I/O operations in a Node.js environment, which is generally not recommended. Consider using asynchronous versions likefs.promises.existsorfs.accesswith a callback to avoid blocking the event loop.
86-87: Assess the logic and security implications of file path handling and existence check.The logic for determining
filePathbased on the parameter might introduce security risks if not properly sanitized, leading to potential directory traversal attacks. Additionally, the use offs.existsSyncshould be replaced with a non-blocking approach. Ensure that all user inputs are properly sanitized before use in file paths.packages/nocodb/src/plugins/vultr/Vultr.ts (1)
63-87: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.packages/nocodb/src/plugins/upcloud/UpoCloud.ts (2)
19-22: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all method calls to
fileCreatematch the new return structure.Verification successful
Verification successful!
The method calls to
fileCreatematch the new return structure across the codebase.
- Instances found in multiple files such as
packages/nocodb/src/plugins/upcloud/UpoCloud.ts,packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts, and others confirm consistent usage.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `fileCreate` match the new return structure. # Test: Search for the method usage. Expect: Only occurances of the new return structure. rg --type python -A 5 $'fileCreate'Length of output: 65
Script:
#!/bin/bash # Description: Verify all method calls to `fileCreate` match the new return structure. # Test: Search for the method usage. Expect: Only occurrences of the new return structure. rg --type ts -A 5 'fileCreate'Length of output: 28646
63-87: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string; }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string; }): Promise<any> {Additionally, ensure that all method calls to
fileCreateByStreammatch the new return structure.packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (2)
19-22: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all method calls to
fileCreatematch the new return structure.
63-87: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string }): Promise<any> {Additionally, ensure that all method calls to
fileCreateByStreammatch the new return structure.packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (2)
19-22: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all method calls to
fileCreatematch the new return structure.Verification successful
All method calls to
fileCreatematch the new return structure.The code changes are verified and consistent across the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `fileCreate` match the new return structure. # Test: Search for the method usage. Expect: Only occurances of the new return structure. rg --type python -A 5 $'fileCreate'Length of output: 65
Script:
#!/bin/bash # Description: Verify all method calls to `fileCreate` match the new return structure. # Test: Search for the method usage in TypeScript files. Expect: Only occurrences of the new return structure. rg --type typescript -A 5 'fileCreate'Length of output: 73
Script:
#!/bin/bash # Description: Verify all method calls to `fileCreate` match the new return structure. # Test: Search for the method usage in `.ts` files. Expect: Only occurrences of the new return structure. rg --type ts -A 5 'fileCreate'Length of output: 28646
63-92: Optimize thefileCreateByStreammethod and add error handling.The method can be simplified by removing the unnecessary promise wrapper and using async/await for better readability and error handling.
- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string; }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string; }): Promise<any> { const uploadParams: any = { ACL: 'public-read', Body: stream, Key: key, }; try { stream.on('error', (err) => { console.log('Stream Error', err); throw err; }); const data = await this.s3Client.upload(uploadParams).promise(); return data.Location; } catch (err) { console.log('Error', err); throw err; } }Additionally, ensure that all method calls to
fileCreateByStreammatch the new return structure.packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! Improved code readability and maintainability.The changes in the
fileCreatemethod improve code readability and maintainability by delegating the upload process tofileCreateByStream.packages/nocodb/src/plugins/mino/Minio.ts (1)
19-21: LGTM! Improved code readability and maintainability.The changes in the
fileCreatemethod improve code readability and maintainability by delegating the upload process tofileCreateByStream.packages/nocodb/src/plugins/s3/S3.ts (4)
32-34: LGTM!The addition of the
optionsparameter with themimetypeproperty tofileCreateByStreamenhances flexibility by allowing dynamic MIME type specification.
54-57: LGTM! But improve error handling.The updated return structure enhances the response by including both the URL and the data. However, improve error handling to provide better insights during debugging.
- .catch((error) => { - throw error; - }); + .catch((error) => { + throw new Error(`Failed to upload file from URL: ${url}. Error: ${error.message}`); + });
63-69: LGTM!The addition of the
optionsparameter with themimetypeproperty tofileCreateByStreamenhances flexibility by allowing dynamic MIME type specification.
81-82: LGTM!Setting the
ContentTypeusing themimetypefrom theoptionsparameter or defaulting toapplication/octet-streamensures correct MIME type handling.packages/nocodb/src/services/public-datas.service.ts (5)
Line range hint
2-24:
LGTM!The new imports for
sharp,IJobsService,JobTypes, andRootScopesare necessary for image processing and job handling.
33-36: LGTM!The addition of the constructor to inject
JobsServiceenables interaction with job-related functionalities, which is essential for the new thumbnail generation feature.
417-432: LGTM!The logic for extracting image metadata (width and height) during file uploads is crucial for generating thumbnails and managing images effectively.
491-513: LGTM!The logic for handling image uploads by URL and extracting metadata using
sharpensures consistency in managing images, whether uploaded directly or by URL.
541-548: LGTM!The logic for adding thumbnail generation jobs using
JobsServiceensures that thumbnails are generated asynchronously, improving performance and user experience.
f05344a to
918d74e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Outside diff range, codebase verification and nitpick comments (1)
packages/nocodb/src/plugins/s3/S3.ts (1)
Line range hint
63-88:
Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string }): Promise<any> {Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (30)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (23)
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/controllers/attachments.controller.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/plugins/storage/Local.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (15)
packages/nc-gui/components/cell/attachment/Image.vue (2)
11-13: LGTM! Explicit increment operation improves clarity.The change from
index.value++toindex.value = index.value + 1enhances readability.
17-26: LGTM! Improved error handling and robustness.The replacement of
<LazyNuxtImg>with<img>and the added conditional check forprops.srcs?.lengthenhance error handling. The binding of:placeholdertoprops.altmaintains functionality.Reminder: Fix the issue with
<LazyNuxtImg>.The TODO comment indicates that the issue with
<LazyNuxtImg>needs to be fixed.packages/nocodb/src/plugins/vultr/Vultr.ts (2)
19-22: LGTM! Improved modularity and reusability.The
fileCreatemethod now delegates the upload logic tofileCreateByStream, enhancing modularity and reusability.
63-87: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype: string }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype: string }): Promise<any> {packages/nocodb/src/plugins/upcloud/UpoCloud.ts (2)
19-22: LGTM! Improved modularity and reusability.The
fileCreatemethod now delegates the upload logic tofileCreateByStream, enhancing modularity and reusability.
63-87: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string; }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string; }): Promise<any> {packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (2)
63-87: Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata.Location. Update the return type toPromise<any>for consistency.- async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string }): Promise<void> { + async fileCreateByStream(key: string, stream: Readable, options?: { mimetype?: string }): Promise<any> {Likely invalid or redundant comment.
19-22: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
fileCreatematch the new signature.Verification successful
Verified: The function
fileCreateis consistently used with the new signature across the codebase.
- The function is defined and used in various files, including different plugins and services.
- All instances align with the expected behavior and signature.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `fileCreate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type python -A 5 $'fileCreate'Length of output: 65
Script:
#!/bin/bash # Description: Verify all function calls to `fileCreate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type js -A 5 $'fileCreate'Length of output: 30
Script:
#!/bin/bash # Description: Verify the definition and all function calls to `fileCreate` match the new signature. # Test: Search for the function definition and usage. Expect: Occurrences of the new signature. rg 'fileCreate' -t js -A 5Length of output: 26
Script:
#!/bin/bash # Description: Verify the definition and all function calls to `fileCreate` match the new signature. # Test: Search for the function definition and usage. Expect: Occurrences of the new signature. rg 'fileCreate' -A 5Length of output: 28636
packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
fileCreatematch the new signature.Verification successful
All function calls to
fileCreatematch the new signature.The code changes are approved.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `fileCreate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type python -A 5 $'fileCreate'Length of output: 65
Script:
#!/bin/bash # Description: Verify all function calls to `fileCreate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type typescript -A 5 'fileCreate'Length of output: 73
Script:
#!/bin/bash # Description: Verify all function calls to `fileCreate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 'fileCreate'Length of output: 28646
packages/nocodb/src/plugins/s3/S3.ts (1)
32-34: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
fileCreatematch the new signature.packages/nocodb/src/services/public-datas.service.ts (5)
2-2: EnsureforwardRef,Inject, andInjectableare necessary.Verify the necessity of these imports for dependency injection.
22-24: EnsureIJobsService,JobTypes, andRootScopesare necessary.Verify the necessity of these imports for the new functionality.
33-36: EnsureJobsServiceis correctly injected.Verify that
JobsServiceis correctly injected and used in the class.Verification successful
Verified
JobsServiceinjection and usage.The
JobsServiceis correctly injected and utilized within thepublic-datas.service.tsfile.
jobsServiceis used in the method callthis.jobsService.add(JobTypes.ThumbnailGenerator, { ... }).Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `JobsService` is correctly injected and used in the class. # Test: Search for `jobsService` usage in the class. Expect: `jobsService` should be used in the class. rg --type ts 'jobsService' packages/nocodb/src/services/public-datas.service.tsLength of output: 193
8-8: Ensuresharpis a dependency.Verify that
sharpis listed as a dependency inpackage.json.
542-548: EnsureJobTypes.ThumbnailGeneratoris correctly used.Verify that
JobTypes.ThumbnailGeneratoris correctly used and the job is added to theJobsService.Verification successful
JobTypes.ThumbnailGeneratoris correctly used.The
JobTypes.ThumbnailGeneratoris correctly defined and used in the codebase. Theaddmethod inJobsServicecorrectly handles adding jobs, includingJobTypes.ThumbnailGenerator.
packages/nocodb/src/interface/Jobs.ts:ThumbnailGenerator = 'thumbnail-generator'packages/nocodb/src/modules/jobs/fallback/jobs.service.ts:addmethod implementationpackages/nocodb/src/modules/jobs/redis/jobs.service.ts:addmethod implementationScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `JobTypes.ThumbnailGenerator` is correctly used and the job is added to the `JobsService`. # Test: Search for `JobTypes.ThumbnailGenerator` usage in the codebase. Expect: `JobTypes.ThumbnailGenerator` should be correctly used. rg --type ts 'JobTypes.ThumbnailGenerator' packages/nocodb/src/Length of output: 644
Script:
#!/bin/bash # Find the definition of `JobTypes.ThumbnailGenerator` rg --type ts 'ThumbnailGenerator' packages/nocodb/src/ # Locate the `add` method in `JobsService` rg --type ts 'add(' packages/nocodb/src/services/jobs.service.ts -A 10Length of output: 2120
Script:
#!/bin/bash # Locate the `add` method in `JobsService` rg --type ts 'add\(' packages/nocodb/src/services/jobs.service.ts -A 10 # Confirm the definition of `JobTypes.ThumbnailGenerator` in `Jobs.ts` rg --type ts 'ThumbnailGenerator' packages/nocodb/src/interface/Jobs.tsLength of output: 337
Script:
#!/bin/bash # Locate the `add` method in the entire `packages/nocodb/src/` directory rg --type ts 'add\(' packages/nocodb/src/ -A 10Length of output: 48533
Script:
#!/bin/bash # Extract the `add` method implementation from `fallback-queue.service.ts` rg --type ts 'add\(' packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts -A 20 # Extract the `add` method implementation from `fallback/jobs.service.ts` rg --type ts 'add\(' packages/nocodb/src/modules/jobs/fallback/jobs.service.ts -A 20 # Extract the `add` method implementation from `redis/jobs.service.ts` rg --type ts 'add\(' packages/nocodb/src/modules/jobs/redis/jobs.service.ts -A 20Length of output: 2535
918d74e to
caf3d0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Outside diff range, codebase verification and nitpick comments (2)
packages/nocodb/src/plugins/storage/Local.ts (1)
Line range hint
33-57:
Change in response type to 'arraybuffer' for axios request.The responseType has been changed from 'stream' to 'arraybuffer'. This change affects how data is handled after download: instead of being streamed directly to a file or another destination, it is now fully loaded into memory before processing.
This might introduce memory inefficiency issues, especially with large files. Consider reverting to 'stream' if handling large files is a common use case, or implement a conditional logic to choose the responseType based on file size.
Refactoring from
createWriteStreamtowriteFilein file handling.The file writing logic has been refactored from using
fs.createWriteStreamtofs.writeFile. This change simplifies the code but removes the benefits of streaming, which can handle large files better by not loading them completely into memory.Consider using
createWriteStreamfor better handling of large files or implement a check to decide the method based on file size.- fs.writeFile(destPath, response.data, (err) => { + const writableStream = fs.createWriteStream(destPath); + writableStream.write(response.data, (err) => {packages/nocodb/src/plugins/s3/S3.ts (1)
Line range hint
63-88:
Ensure proper error handling and return type consistency.The
fileCreateByStreammethod correctly handles asynchronous file uploads using promises. However, the return type in the method signature isPromise<void>, but the promise resolves withdata. Update the return type toPromise<any>for consistency.- ): Promise<void> { + ): Promise<any> {Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (30)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (20)
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/controllers/attachments.controller.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (17)
packages/nc-gui/components/cell/attachment/Image.vue (2)
11-13: LGTM!The explicit increment operation enhances clarity.
17-26: LGTM!The changes improve robustness and error handling. However, remember to address the TODO comment regarding the
<LazyNuxtImg>component.packages/nocodb/src/plugins/vultr/Vultr.ts (1)
19-22: LGTM!The refactoring centralizes the S3 upload logic, improving maintainability.
packages/nocodb/src/plugins/upcloud/UpoCloud.ts (1)
19-22: LGTM!The changes improve the clarity and efficiency of file upload operations.
packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (1)
19-22: LGTM!The
fileCreatefunction correctly reads the file and callsfileCreateByStream.packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
19-22: LGTM!The
fileCreatefunction correctly reads the file and callsfileCreateByStream.packages/nocodb/src/plugins/storage/Local.ts (1)
Line range hint
63-75:
LGTM!The
fileCreateByStreamfunction correctly creates a writable stream and pipes the input stream to it.packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! The changes improve modularity and readability.The method now correctly delegates the upload process to
fileCreateByStreamand passes the MIME type.packages/nocodb/src/plugins/s3/S3.ts (1)
32-34: LGTM! The changes improve modularity and readability.The method now correctly delegates the upload process to
fileCreateByStreamand passes the MIME type.packages/nocodb/src/services/public-datas.service.ts (8)
2-3: LGTM! Import statements are appropriate.The added imports for
sharp,IJobsService,JobTypes, andRootScopesare necessary for the new thumbnail generation feature and are correctly included.Also applies to: 8-8, 22-24
33-36: LGTM! Constructor forJobsServiceinjection is correct.The constructor correctly injects the
JobsServiceusing dependency injection.
417-421: InitializetempMetaobject with default values.To avoid potential issues with undefined values, initialize the
tempMetaobject with default values.- const tempMeta: { - width?: number; - height?: number; - } = {}; + const tempMeta: { + width: number; + height: number; + } = { width: 0, height: 0 };
422-432: Handle image metadata extraction errors gracefully.Ensure that any errors during image metadata extraction are logged for debugging purposes.
- } catch (e) { - // Ignore-if file is not image - } + } catch (e) { + console.error('Error extracting image metadata:', e); + }
496-500: InitializetempMetadataobject with default values.To avoid potential issues with undefined values, initialize the
tempMetadataobject with default values.- const tempMetadata: { - width?: number; - height?: number; - } = {}; + const tempMetadata: { + width: number; + height: number; + } = { width: 0, height: 0 };
501-513: Handle image metadata extraction errors gracefully.Ensure that any errors during image metadata extraction are logged for debugging purposes.
- } catch (e) { - // Might be invalid image - ignore - } + } catch (e) { + console.error('Error extracting image metadata:', e); + }
456-456: LGTM! Metadata inclusion in attachments is correct.The inclusion of extracted metadata in the attachment objects is correct.
Also applies to: 534-534
542-548: LGTM! But verify the job type handling inJobsService.The code changes for adding the thumbnail generation job are approved.
However, ensure that the job type
ThumbnailGeneratoris correctly handled in theJobsService.Verification successful
Let's generate a new script to search for the handling of
JobTypes.ThumbnailGeneratorin the codebase.
The job type
ThumbnailGeneratoris handled correctly in theJobsService.The search results confirm that
JobTypes.ThumbnailGeneratoris integrated and processed properly in the job processing system.
thumbnail-generator.processor.ts: The job type is processed.fallback-queue.service.ts: The job type is included in the fallback queue.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the job type `ThumbnailGenerator` handling in `JobsService`. # Test: Search for the job type handling. Expect: Proper handling of `ThumbnailGenerator`. rg --type typescript -A 5 $'JobTypes.ThumbnailGenerator'Length of output: 90
Script:
#!/bin/bash # Description: Verify the job type `ThumbnailGenerator` handling in `JobsService`. # Test: Search for the job type handling. Expect: Proper handling of `ThumbnailGenerator`. rg 'JobTypes.ThumbnailGenerator' -A 5Length of output: 2833
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
Show resolved
Hide resolved
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
Show resolved
Hide resolved
packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
Show resolved
Hide resolved
caf3d0f to
77bc13b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Outside diff range, codebase verification and nitpick comments (2)
packages/nocodb/src/plugins/storage/Local.ts (1)
Line range hint
33-57:
Consider reverting to 'stream' for responseType and usingcreateWriteStreamfor better handling of large files.The change in response type to 'arraybuffer' might introduce memory inefficiency issues, especially with large files. The change in file writing logic removes the benefits of streaming, which can handle large files better by not loading them completely into memory.
- responseType: 'arraybuffer', + responseType: 'stream', - fs.writeFile(destPath, response.data, (err) => { + const writableStream = fs.createWriteStream(destPath); + response.data.pipe(writableStream); + writableStream.on('finish', () => resolve({ + url: null, + data: response.data, + })); + writableStream.on('error', (err) => reject(err));packages/nocodb/src/plugins/s3/S3.ts (1)
Line range hint
63-82:
Simplify the promise wrapper using async/await.The method can be simplified by removing the unnecessary promise wrapper and using async/await for better readability and error handling.
- return new Promise((resolve, reject) => { - stream.on('error', (err) => { - console.log('File Error', err); - reject(err); - }); - const uploadParams: any = { - ...this.defaultParams, - Body: stream, - Key: key, - ContentType: options?.mimetype || 'application/octet-stream', - }; - this.upload(uploadParams) - .then((data) => { - resolve(data); - }) - .catch((err) => { - reject(err); - }); - }); + try { + stream.on('error', (err) => { + console.log('File Error', err); + throw err; + }); + const uploadParams: any = { + ...this.defaultParams, + Body: stream, + Key: key, + ContentType: options?.mimetype || 'application/octet-stream', + }; + const data = await this.upload(uploadParams); + return data; + } catch (err) { + console.log('Error', err); + throw err; + }Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (30)
- packages/nc-gui/components/cell/attachment/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (2 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (20)
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (16)
packages/nc-gui/components/cell/attachment/Image.vue (2)
11-13: LGTM!The explicit increment operation improves code clarity.
17-26: LGTM!The changes in the
<img>element resolve issues with error handling and ensure robustness.Reminder: Fix the issue with
<LazyNuxtImg>.The TODO comment indicates that the issue with
<LazyNuxtImg>needs to be fixed.packages/nocodb/src/plugins/vultr/Vultr.ts (1)
19-22: LGTM!Centralizing the S3 upload logic within
fileCreateByStreamimproves code reuse and maintainability.packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
19-22: LGTM! The refactoring simplifies the code.The refactoring of the
fileCreatemethod to use thefileCreateByStreammethod is logical and simplifies the code.packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! The refactoring simplifies the code.The refactoring of the
fileCreatemethod to use thefileCreateByStreammethod is logical and simplifies the code.packages/nocodb/src/plugins/mino/Minio.ts (1)
19-21: LGTM! The changes improve code reuse and return value.The function now reuses the
fileCreateByStreammethod and provides more information in the return value.packages/nocodb/src/plugins/s3/S3.ts (1)
32-34: LGTM! The changes improve code reuse and return value.The function now reuses the
fileCreateByStreammethod and provides more information in the return value.packages/nocodb/src/services/public-datas.service.ts (9)
2-2: LGTM! Dependency injection imports added.The imports for
forwardRef,Inject, andInjectablefrom@nestjs/commonare correctly added to support dependency injection.
8-8: LGTM! Sharp library imported for image processing.The import of the
sharplibrary is appropriate for handling image processing tasks required for the thumbnail generator feature.
22-24: LGTM! Job-related imports added.The imports for
IJobsService,JobTypes, andRootScopesare correctly added to support job management for the thumbnail generator feature.
33-36: LGTM! Constructor added for dependency injection.The constructor correctly injects the
JobsServiceusing NestJS's dependency injection mechanism.
417-421: InitializetempMetaobject with default values.To avoid potential issues with undefined values, initialize the
tempMetaobject with default values.- const tempMeta: { - width?: number; - height?: number; - } = {}; + const tempMeta: { + width: number; + height: number; + } = { width: 0, height: 0 };
422-432: Handle image metadata extraction errors gracefully.Ensure that any errors during image metadata extraction are logged for debugging purposes.
- } catch (e) { - // Ignore-if file is not image - } + } catch (e) { + console.error('Error extracting image metadata:', e); + }
496-500: InitializetempMetadataobject with default values.To avoid potential issues with undefined values, initialize the
tempMetadataobject with default values.- const tempMetadata: { - width?: number; - height?: number; - } = {}; + const tempMetadata: { + width: number; + height: number; + } = { width: 0, height: 0 };
501-513: Handle image metadata extraction errors gracefully.Ensure that any errors during image metadata extraction are logged for debugging purposes.
- } catch (e) { - // Might be invalid image - ignore - } + } catch (e) { + console.error('Error extracting image metadata:', e); + }
542-548: LGTM! Job for thumbnail generation added.The addition of a job for thumbnail generation using
JobsServicealigns with the PR's objective and is correctly implemented.
77bc13b to
e940832
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 15
Outside diff range, codebase verification and nitpick comments (2)
packages/nc-gui/components/cell/attachment/Preview/Image.vue (1)
15-32: Reminder: Address the TODO comment.The TODO comment indicates a known issue with the
nuxt-imagecomponent. Ensure to fix this later as mentioned.packages/nocodb/src/plugins/s3/S3.ts (1)
Line range hint
63-82:
Simplify the promise wrapper using async/await.The method can be simplified by removing the unnecessary promise wrapper and using async/await for better readability and error handling.
- return new Promise((resolve, reject) => { - stream.on('error', (err) => { - console.log('File Error', err); - reject(err); - }); - - uploadParams.Body = stream; - uploadParams.Key = key; - uploadParams.ContentType = - options?.mimetype || 'application/octet-stream'; - - // call S3 to upload file to specified bucket - this.upload(uploadParams) - .then((data) => { - resolve(data); - }) - .catch((err) => { - reject(err); - }); - }); + try { + stream.on('error', (err) => { + console.log('File Error', err); + throw err; + }); + + uploadParams.Body = stream; + uploadParams.Key = key; + uploadParams.ContentType = + options?.mimetype || 'application/octet-stream'; + + // call S3 to upload file to specified bucket + const data = await this.upload(uploadParams); + return data; + } catch (err) { + console.log('Error', err); + throw err; + }Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (31)
- packages/nc-gui/components/cell/attachment/Carousel.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (2 hunks)
- packages/nc-gui/components/cell/attachment/Preview/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (3 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (18)
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (19)
packages/nc-gui/components/cell/attachment/Preview/Image.vue (3)
1-13: LGTM!The script setup block is clean and follows best practices. Props are well-defined, and the error handling function is implemented correctly.
15-32: LGTM!The template block is well-configured with lazy loading and error handling for the image element.
33-33: LGTM!The template block closes correctly.
packages/nocodb/src/plugins/vultr/Vultr.ts (2)
50-53: LGTM!The
fileCreateByUrlmethod is well-implemented with proper error handling and structured response.
63-87: Ensure proper return type consistency.The
fileCreateByStreammethod resolves withdata.Location, but the return type isPromise<void>. Update the return type toPromise<any>for consistency.- ): Promise<void> { + ): Promise<any> {Likely invalid or redundant comment.
packages/nocodb/src/plugins/upcloud/UpoCloud.ts (1)
50-53: LGTM!The
fileCreateByUrlmethod is well-implemented with proper error handling and structured response.packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
19-22: LGTM! Simplified the upload process.The changes simplify the upload process by directly creating a file stream and passing it to
fileCreateByStream. The MIME type is handled through an optional parameter.packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! Simplified the upload process.The changes simplify the upload process by directly creating a file stream and passing it to
fileCreateByStream. The MIME type is handled through an optional parameter.packages/nocodb/src/plugins/mino/Minio.ts (1)
19-21: LGTM!The changes to the
fileCreatemethod are clear and improve the utility by returning more information.packages/nocodb/src/plugins/s3/S3.ts (1)
32-34: LGTM!The changes to the
fileCreatemethod are clear and improve the utility by returning more information.packages/nc-gui/components/cell/attachment/Carousel.vue (2)
84-134: Enhanced carousel functionality and structured layout.The additions of
NcButtonandNcCarouselcomponents improve the carousel's functionality and user interface. Ensure that these components are thoroughly tested for various attachment types.
135-150: Enhanced user interaction with tooltips and rename buttons.The additions of tooltips and buttons for renaming files enrich user interaction capabilities within the carousel. Ensure that the conditions for displaying the rename functionality are tested under various scenarios.
packages/nc-gui/components/cell/attachment/Modal.vue (2)
37-37: Optimized image source management with additional parameter.The addition of the
'card_cover'parameter to thegetPossibleAttachmentSrcmethod optimizes image previews within the modal. Ensure that the method is tested with various attachment types to verify the correct image source retrieval.
116-133: Enhanced modal functionality with checkboxes and optimized image previews.The additions of
NcCheckboxandLazyCellAttachmentPreviewImagecomponents enhance the modal's functionality. Ensure that these components are thoroughly tested for various attachment types and scenarios.packages/nocodb/src/services/public-datas.service.ts (4)
2-8: Integrated necessary dependencies for new functionality.The additions of
forwardRef,Inject,Injectable, andsharpimports integrate necessary dependencies for image processing and job management. Ensure that these dependencies are correctly configured and utilized.
22-24: Integrated additional dependencies for job management and global scope handling.The additions of
IJobsService,JobTypes, andRootScopesimports integrate additional dependencies for job management and global scope handling. Ensure that these dependencies are correctly configured and utilized.
33-36: Enhanced job management capabilities withJobsServiceinjection.The addition of a constructor for injecting
JobsServiceenhances job management capabilities within thePublicDatasServiceclass. Ensure that theJobsServiceis correctly injected and utilized across the class.
542-548: Enhanced file creation process with thumbnail generation job.The addition of a job for generating thumbnails using the
JobsServiceenhances the file creation process. Ensure that the job is correctly configured and tested for various attachment types.packages/nocodb/src/db/BaseModelSqlv2.ts (1)
8596-8597: Ensure width and height properties are correctly handledThe addition of width and height properties to attachments should be verified for correctness. Ensure that these properties are correctly extracted and validated.
e940832 to
436bc5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
Outside diff range, codebase verification and nitpick comments (2)
packages/nc-gui/components/cell/attachment/Preview/Image.vue (1)
Line range hint
1-10:
Handle the case where all images fail to load.The
onErrorfunction should handle the case where all images in thesrcsarray fail to load to prevent an infinite loop.- const onError = () => index.value++ + const onError = () => { + if (index.value < props.srcs.length - 1) { + index.value++ + } + }packages/nocodb/src/plugins/s3/S3.ts (1)
Line range hint
63-88:
Simplify the promise wrapper using async/await and verify error handling.The
fileCreateByStreammethod can be simplified by removing the unnecessary promise wrapper and using async/await for better readability and error handling.- return new Promise((resolve, reject) => { - stream.on('error', (err) => { - console.log('File Error', err); - reject(err); - }); - uploadParams.Body = stream; - uploadParams.Key = key; - uploadParams.ContentType = options?.mimetype || 'application/octet-stream'; - this.upload(uploadParams) - .then((data) => { - resolve(data); - }) - .catch((err) => { - reject(err); - }); - }); + try { + stream.on('error', (err) => { + console.log('File Error', err); + throw err; + }); + uploadParams.Body = stream; + uploadParams.Key = key; + uploadParams.ContentType = options?.mimetype || 'application/octet-stream'; + const data = await this.upload(uploadParams); + return data; + } catch (err) { + console.log('Error', err); + throw err; + }Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (31)
- packages/nc-gui/components/cell/attachment/Carousel.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (2 hunks)
- packages/nc-gui/components/cell/attachment/Preview/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (5 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (23)
- packages/nc-gui/components/cell/attachment/Carousel.vue
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/plugins/storage/Local.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (7)
packages/nc-gui/components/cell/attachment/Preview/Image.vue (1)
16-29: LGTM!The template section correctly handles image loading errors and provides a fallback component.
packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
19-22: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all calls to
fileCreatecorrectly pass the file object with themimetypeproperty.Verification successful
LGTM! The method usage has been verified and all calls to
fileCreatecorrectly pass the file object with themimetypeproperty.
- All instances of
fileCreatecorrectly include themimetypeproperty.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `fileCreate` pass the file object with the `mimetype` property. # Test: Search for the method usage. Expect: Only occurances of the new signature. rg --type python -A 5 $'fileCreate'Length of output: 65
Script:
#!/bin/bash # Description: Verify all calls to `fileCreate` pass the file object with the `mimetype` property. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type typescript -A 5 'fileCreate'Length of output: 73
Script:
#!/bin/bash # Description: Verify all calls to `fileCreate` pass the file object with the `mimetype` property. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 'fileCreate'Length of output: 28665
packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all calls to
fileCreatecorrectly pass the file object with themimetypeproperty.Verification successful
LGTM! The
fileCreatemethod is correctly called with thefileobject containing themimetypeproperty across the codebase.
- Instances in
attachments.service.ts,public-datas.service.ts,LinodeObjectStorage.ts,Vultr.ts,Backblaze.ts,UpoCloud.ts,ScalewayObjectStorage.ts,Spaces.ts,S3.ts,Gcs.ts,OvhCloud.ts,Minio.ts,Local.ts, andIStorageAdapter.tsconfirm the correct usage.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `fileCreate` pass the file object with the `mimetype` property. # Test: Search for the method usage. Expect: Only occurances of the new signature. rg --type python -A 5 $'fileCreate'Length of output: 65
Script:
#!/bin/bash # Description: Verify all calls to `fileCreate` pass the file object with the `mimetype` property. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 'fileCreate'Length of output: 28665
packages/nocodb/src/controllers/attachments.controller.ts (1)
168-169: LGTM!The introduction of the
filePathvariable enhances flexibility in path construction.packages/nocodb/src/services/public-datas.service.ts (3)
8-8: LGTM!The import of the
sharplibrary for image processing is appropriate.
33-36: LGTM!The constructor correctly uses dependency injection to inject the
JobsService.
542-548: LGTM!The addition of the job for thumbnail generation is appropriate and correctly implemented.
436bc5f to
c071df4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 11
Outside diff range, codebase verification and nitpick comments (1)
packages/nocodb/src/plugins/s3/S3.ts (1)
Line range hint
63-88:
Simplify the promise wrapper using async/await.The
fileCreateByStreammethod can be simplified by removing the unnecessary promise wrapper and using async/await for better readability and error handling.- return new Promise((resolve, reject) => { - stream.on('error', (err) => { - console.log('File Error', err); - reject(err); - }); - uploadParams.Body = stream; - uploadParams.Key = key; - uploadParams.ContentType = options?.mimetype || 'application/octet-stream'; - this.upload(uploadParams) - .then((data) => { - resolve(data); - }) - .catch((err) => { - reject(err); - }); - }); + try { + stream.on('error', (err) => { + console.log('File Error', err); + throw err; + }); + uploadParams.Body = stream; + uploadParams.Key = key; + uploadParams.ContentType = options?.mimetype || 'application/octet-stream'; + const data = await this.upload(uploadParams); + return data; + } catch (err) { + throw err; + }Tools
Biome
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (31)
- packages/nc-gui/components/cell/attachment/Carousel.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/Modal.vue (2 hunks)
- packages/nc-gui/components/cell/attachment/Preview/Image.vue (1 hunks)
- packages/nc-gui/components/cell/attachment/index.vue (5 hunks)
- packages/nc-gui/components/smartsheet/Gallery.vue (1 hunks)
- packages/nc-gui/components/smartsheet/Kanban.vue (1 hunks)
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue (1 hunks)
- packages/nc-gui/components/virtual-cell/components/ListItem.vue (1 hunks)
- packages/nc-gui/composables/useAttachment.ts (1 hunks)
- packages/nocodb/.gitignore (1 hunks)
- packages/nocodb/src/controllers/attachments-secure.controller.ts (2 hunks)
- packages/nocodb/src/controllers/attachments.controller.ts (4 hunks)
- packages/nocodb/src/db/BaseModelSqlv2.ts (2 hunks)
- packages/nocodb/src/interface/Jobs.ts (3 hunks)
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts (3 hunks)
- packages/nocodb/src/modules/jobs/jobs.module.ts (2 hunks)
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts (1 hunks)
- packages/nocodb/src/modules/noco.module.ts (2 hunks)
- packages/nocodb/src/plugins/backblaze/Backblaze.ts (3 hunks)
- packages/nocodb/src/plugins/gcs/Gcs.ts (3 hunks)
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/mino/Minio.ts (3 hunks)
- packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (3 hunks)
- packages/nocodb/src/plugins/s3/S3.ts (3 hunks)
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts (3 hunks)
- packages/nocodb/src/plugins/spaces/Spaces.ts (3 hunks)
- packages/nocodb/src/plugins/storage/Local.ts (2 hunks)
- packages/nocodb/src/plugins/upcloud/UpoCloud.ts (3 hunks)
- packages/nocodb/src/plugins/vultr/Vultr.ts (3 hunks)
- packages/nocodb/src/services/attachments.service.ts (9 hunks)
- packages/nocodb/src/services/public-datas.service.ts (7 hunks)
Files skipped from review as they are similar to previous changes (23)
- packages/nc-gui/components/cell/attachment/Carousel.vue
- packages/nc-gui/components/cell/attachment/Modal.vue
- packages/nc-gui/components/cell/attachment/index.vue
- packages/nc-gui/components/smartsheet/Gallery.vue
- packages/nc-gui/components/smartsheet/Kanban.vue
- packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
- packages/nc-gui/components/virtual-cell/components/ListItem.vue
- packages/nc-gui/composables/useAttachment.ts
- packages/nocodb/.gitignore
- packages/nocodb/src/controllers/attachments-secure.controller.ts
- packages/nocodb/src/db/BaseModelSqlv2.ts
- packages/nocodb/src/interface/Jobs.ts
- packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
- packages/nocodb/src/modules/jobs/jobs.module.ts
- packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
- packages/nocodb/src/modules/noco.module.ts
- packages/nocodb/src/plugins/gcs/Gcs.ts
- packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
- packages/nocodb/src/plugins/mino/Minio.ts
- packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
- packages/nocodb/src/plugins/spaces/Spaces.ts
- packages/nocodb/src/plugins/storage/Local.ts
- packages/nocodb/src/services/attachments.service.ts
Additional context used
Biome
packages/nocodb/src/plugins/s3/S3.ts
[error] 59-59: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
Additional comments not posted (13)
packages/nc-gui/components/cell/attachment/Preview/Image.vue (2)
Line range hint
1-9:
LGTM!The
<script setup>section is well-structured, correctly defining the props and setting up error handling.
16-29: LGTM!The
<template>section effectively handles image loading errors and provides a fallback component. The usage ofv-ifand@erroris appropriate.packages/nocodb/src/plugins/vultr/Vultr.ts (2)
50-53: LGTM!The
fileCreateByUrlmethod correctly handles file creation by URL, including proper error handling and response processing.
19-22: Ensure proper return type consistency.The
fileCreatemethod returns a structured response. Update the return type for consistency.- async fileCreate(key: string, file: XcFile): Promise<any> { + async fileCreate(key: string, file: XcFile): Promise<{ url: string; data: any; }> {Likely invalid or redundant comment.
packages/nocodb/src/plugins/upcloud/UpoCloud.ts (1)
50-53: LGTM!The
fileCreateByUrlmethod correctly handles file creation by URL, including proper error handling and response processing.packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts (1)
19-22: LGTM!The refactoring to use
fileCreateByStreamimproves code reuse and readability.packages/nocodb/src/plugins/backblaze/Backblaze.ts (1)
19-22: LGTM!The refactoring to use
fileCreateByStreamimproves code reuse and readability.packages/nocodb/src/plugins/s3/S3.ts (1)
32-34: LGTM!The refactoring to use
fileCreateByStreamimproves code reuse and readability.packages/nocodb/src/controllers/attachments.controller.ts (1)
2-2: Import statement forfsis correct.The import statement for
fsis necessary for the subsequent file operations.packages/nocodb/src/services/public-datas.service.ts (4)
8-8: Import statement forsharpis correct.The import statement for
sharpis necessary for image processing.
22-24: Import statements for job-related modules are correct.The import statements for
IJobsService,JobTypes, andRootScopesare necessary for job management.
34-39: Constructor for injectingJobsServiceis correct.The constructor is correctly implemented to inject the
JobsServicefor job management.
544-550: Job addition for thumbnail generation is correct.The job addition for thumbnail generation using
JobsServiceis correctly implemented to enhance image handling.
Change Summary
Closes #5207
Change type