mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 01:36:30 +02:00
feat: add real-time folder watcher registration and unregistration for Local Folder connector
This commit is contained in:
parent
b93da843dc
commit
543b8b9376
1 changed files with 28 additions and 0 deletions
|
|
@ -586,6 +586,23 @@ export const useConnectorDialog = () => {
|
|||
},
|
||||
});
|
||||
|
||||
// Register folder watcher in Electron for real-time sync
|
||||
if (
|
||||
currentConnectorType === EnumConnectorName.LOCAL_FOLDER_CONNECTOR &&
|
||||
window.electronAPI?.addWatchedFolder
|
||||
) {
|
||||
const cfg = connector.config || {};
|
||||
await window.electronAPI.addWatchedFolder({
|
||||
path: cfg.folder_path as string,
|
||||
name: cfg.folder_name as string,
|
||||
excludePatterns: (cfg.exclude_patterns as string[]) || [],
|
||||
fileExtensions: (cfg.file_extensions as string[] | null) ?? null,
|
||||
connectorId: connector.id,
|
||||
searchSpaceId: Number(searchSpaceId),
|
||||
active: true,
|
||||
});
|
||||
}
|
||||
|
||||
const successMessage =
|
||||
currentConnectorType === "MCP_CONNECTOR"
|
||||
? `${connector.name} added successfully`
|
||||
|
|
@ -1190,6 +1207,17 @@ export const useConnectorDialog = () => {
|
|||
id: editingConnector.id,
|
||||
});
|
||||
|
||||
// Unregister folder watcher in Electron when removing a Local Folder connector
|
||||
if (
|
||||
editingConnector.connector_type === EnumConnectorName.LOCAL_FOLDER_CONNECTOR &&
|
||||
window.electronAPI?.removeWatchedFolder &&
|
||||
editingConnector.config?.folder_path
|
||||
) {
|
||||
await window.electronAPI.removeWatchedFolder(
|
||||
editingConnector.config.folder_path as string
|
||||
);
|
||||
}
|
||||
|
||||
// Track connector deleted event
|
||||
trackConnectorDeleted(
|
||||
Number(searchSpaceId),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue