Skip to content

Commit

Permalink
fix: googledrive: folders getting synced with files
Browse files Browse the repository at this point in the history
  • Loading branch information
amuwal committed Dec 20, 2024
1 parent 3dd7a08 commit b6dd9b6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/api/src/filestorage/file/services/googledrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ export class GoogleDriveService implements IFileService {
).values(),
);

this.logger.log(
`Ingesting ${uniquePermissions.length} unique permissions.`,
);

// Ingest permissions using the ingestService
const syncedPermissions = await this.ingestService.ingestData<
UnifiedFilestoragePermissionOutput,
Expand All @@ -95,6 +91,10 @@ export class GoogleDriveService implements IFileService {
'permission',
);

this.logger.log(
`Ingested ${uniquePermissions.length} permissions for googledrive files.`,
);

// Create a map of original permission ID to synced permission ID
const permissionIdMap: Map<string, string> = new Map(
syncedPermissions.map((permission) => [
Expand Down Expand Up @@ -193,6 +193,8 @@ export class GoogleDriveService implements IFileService {
custom_field_mappings,
ingestParams,
);

this.logger.log(`Ingested a batch of ${files.length} googledrive files.`);
}

if (nextPageTokenFiles || nextPageTokenFolders) {
Expand All @@ -205,9 +207,12 @@ export class GoogleDriveService implements IFileService {
pageTokenFolders: nextPageTokenFolders,
connectionId: connection.id_connection,
});
} else {
this.logger.log(
`No more files to sync for googledrive for linked user ${linkedUserId}.`,
);
}

console.log(`Processed a batch of ${files.length} files.`);
return {
data: [],
message: 'Google Drive sync completed for this batch',
Expand Down Expand Up @@ -274,7 +279,7 @@ export class GoogleDriveService implements IFileService {
foldersResponse.data.files.map((folder) =>
this.rateLimitedRequest<DriveResponse>(() =>
drive.files.list({
q: `'${folder.id}' in parents`,
q: `'${folder.id}' in parents and mimeType!='application/vnd.google-apps.folder'`,
fields:
'nextPageToken, files(id, name, mimeType, createdTime, modifiedTime, size, parents, webViewLink, driveId, permissions, trashed)',
pageSize: BATCH_SIZE,
Expand Down

0 comments on commit b6dd9b6

Please sign in to comment.