-
Notifications
You must be signed in to change notification settings - Fork 36.9k
Watch and remove file attachments that are deleted #283387
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR implements automatic removal of file attachments when the underlying files are deleted from the file system. It adds a file system change listener to the ChatAttachmentModel that monitors for file deletion events and removes corresponding attachments from the model.
Key Changes:
- Added file system change listener to detect deleted file attachments
- Automatically removes deleted files from the attachment list via the existing
updateContextmethod
| return; | ||
| } | ||
|
|
||
| const watcher = this.fileService.createWatcher(uri, { recursive: false, excludes: [] }); |
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.
Is there a cost with creating many watchers? In a dumb case when I have tons of files attached, is it bad to create 20 of these and have them around for a long time?
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.
The comment on IFileService says to prefer correlated watchers - otherwise events get fired to every watcher.
Looking through the watchers code it seems that the cost of creating a watcher is a couple of entries in hash tables, so I think it's reasonable.
Perhaps @bpasero can provide more specific guidance.
Fixes #282900