mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 22:02:39 +02:00
fix(connectors): track delta sync tokens per folder for Google Drive
- Store tokens in folder_tokens dict instead of single global token - Each folder now tracks its own sync state independently - Fixes issue where indexing folder 2 incorrectly used delta sync after folder 1 was indexed - First-time indexing now correctly uses full scan for each new folder
This commit is contained in:
parent
a5935bc677
commit
506a9297a9
2 changed files with 8 additions and 3 deletions
|
|
@ -112,8 +112,9 @@ async def index_google_drive_files(
|
|||
|
||||
logger.info(f"Indexing Google Drive folder: {target_folder_name} ({target_folder_id})")
|
||||
|
||||
# Decide sync strategy
|
||||
start_page_token = connector.config.get("start_page_token")
|
||||
# Decide sync strategy - track tokens per folder
|
||||
folder_tokens = connector.config.get("folder_tokens", {})
|
||||
start_page_token = folder_tokens.get(target_folder_id)
|
||||
can_use_delta_sync = use_delta_sync and start_page_token and connector.last_indexed_at
|
||||
|
||||
if can_use_delta_sync:
|
||||
|
|
@ -156,7 +157,10 @@ async def index_google_drive_files(
|
|||
if new_token and not token_error:
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
|
||||
connector.config["start_page_token"] = new_token
|
||||
# Store token per folder
|
||||
if "folder_tokens" not in connector.config:
|
||||
connector.config["folder_tokens"] = {}
|
||||
connector.config["folder_tokens"][target_folder_id] = new_token
|
||||
flag_modified(connector, "config")
|
||||
|
||||
await update_connector_last_indexed(session, connector, update_last_indexed)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export const documentTypeEnum = z.enum([
|
|||
"CLICKUP_CONNECTOR",
|
||||
"GOOGLE_CALENDAR_CONNECTOR",
|
||||
"GOOGLE_GMAIL_CONNECTOR",
|
||||
"GOOGLE_DRIVE_CONNECTOR",
|
||||
"AIRTABLE_CONNECTOR",
|
||||
"LUMA_CONNECTOR",
|
||||
"ELASTICSEARCH_CONNECTOR",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue