Skip to content
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

Add files deletion when destroying attachment, workspace or workspaceMember #10222

Merged
merged 7 commits into from
Feb 20, 2025

Conversation

etiennejouan
Copy link
Contributor

@etiennejouan etiennejouan commented Feb 14, 2025

Solution

  • update attachment soft delete logic by destroy (seen with Weiko & Felix)
  • add two jobs for file and workspace folder deletion
  • add listener to attachment and workspaceMember destroy event -> add file deletion job
  • update logic in deleteWorkspace method -> add wokspace folder deletion job

closes twentyhq/core-team-issues#147

To go further

  • delete old avatar when workspaceMember replaces its avatar
  • same with workspace picture

@etiennejouan etiennejouan changed the title Add associated files deletion when destroying attachment, workspace or workspaceMember Add files deletion when destroying attachment, workspace or workspaceMember Feb 14, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR implements a comprehensive file cleanup system for handling file deletions when attachments, workspace members, or workspaces are destroyed.

  • Added FileAttachmentListener and FileWorkspaceMemberListener in /packages/twenty-server/src/engine/core-modules/file/listeners/ to handle file cleanup on entity deletion
  • Implemented FileDeletionJob and FileWorkspaceFolderDeletionJob in /packages/twenty-server/src/engine/core-modules/file/jobs/ for queued file deletion operations
  • Enhanced FileService with deleteFile and deleteWorkspaceFolder methods for safe file system operations
  • Updated attachment handling in /packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx to use useDestroyOneRecord instead of soft deletion
  • Modified WorkspaceService to include file cleanup when deleting workspaces

Note: Consider adding error handling for file system operations and handling null/undefined avatar URLs in the workspace member listener.

8 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! You can merge and ignore the queue comment if you want, not sure if it's a must

@etiennejouan etiennejouan enabled auto-merge (squash) February 20, 2025 09:32
@etiennejouan etiennejouan merged commit 316876f into main Feb 20, 2025
47 checks passed
@etiennejouan etiennejouan deleted the ej/147 branch February 20, 2025 09:35
Copy link
Contributor

Thanks @etiennejouan for your contribution!
This marks your 26th PR on the repo. You're top 2% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle deletion of files
2 participants