Skip to content

Commit

Permalink
fix: add sync user id aget_files (#3261)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineDiro authored Sep 25, 2024
1 parent ebeb41e commit 0c90254
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions backend/api/quivr_api/modules/sync/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ def get_files(
raise Exception("Failed to retrieve files")

async def aget_files(
self, credentials: Dict, folder_id: str | None = None, recursive: bool = False
self,
credentials: Dict,
folder_id: str | None = None,
recursive: bool = False,
sync_user_id: int | None = None,
) -> List[SyncFile]:
return self.get_files(credentials, folder_id, recursive)

Expand Down Expand Up @@ -476,7 +480,11 @@ def fetch_files(endpoint, headers, max_retries=1):
return files

async def aget_files(
self, credentials: Dict, folder_id: str | None = None, recursive: bool = False
self,
credentials: Dict,
folder_id: str | None = None,
recursive: bool = False,
sync_user_id: int | None = None,
) -> List[SyncFile]:
return self.get_files(credentials, folder_id, recursive)

Expand Down Expand Up @@ -670,7 +678,11 @@ def fetch_files(metadata):
raise Exception("Failed to retrieve files")

async def aget_files(
self, credentials: Dict, folder_id: str | None = None, recursive: bool = False
self,
credentials: Dict,
folder_id: str | None = None,
recursive: bool = False,
sync_user_id: int | None = None,
) -> List[SyncFile]:
return self.get_files(credentials, folder_id, recursive)

Expand Down Expand Up @@ -788,10 +800,11 @@ def check_and_refresh_access_token(self, credentials: Dict) -> Dict:
async def aget_files(
self,
credentials: Dict,
sync_user_id: int,
folder_id: str | None = None,
recursive: bool = False,
sync_user_id: int | None = None,
) -> List[SyncFile]:
assert sync_user_id, "should not be optional for notion"
pages = []

if not self.notion:
Expand All @@ -818,7 +831,12 @@ async def aget_files(
pages.append(page_info)

if recursive:
sub_pages = await self.aget_files(credentials=credentials, sync_user_id=sync_user_id, folder_id=str(page.id), recursive=recursive)
sub_pages = await self.aget_files(
credentials=credentials,
sync_user_id=sync_user_id,
folder_id=str(page.id),
recursive=recursive,
)
pages.extend(sub_pages)
return pages

Expand Down Expand Up @@ -1035,7 +1053,11 @@ def get_files(
return self.list_github_repos(credentials, recursive=recursive)

async def aget_files(
self, credentials: Dict, folder_id: str | None = None, recursive: bool = False
self,
credentials: Dict,
folder_id: str | None = None,
recursive: bool = False,
sync_user_id: int | None = None,
) -> List[SyncFile]:
return self.get_files(credentials, folder_id, recursive)

Expand Down

0 comments on commit 0c90254

Please sign in to comment.