Skip to content

Commit

Permalink
fix: source URL for google drive files (#9167)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Dec 5, 2024
1 parent 20894c4 commit 102e2bb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions connectors/src/connectors/google_drive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
title: f.name || "",
dustDocumentId: getGoogleDriveEntityDocumentId(f),
lastUpdatedAt: f.lastUpsertedTs?.getTime() || null,
sourceUrl: null,
sourceUrl: getSourceUrlForGoogleDriveFiles(f),
expandable: await isDriveObjectExpandable({
objectId: f.driveFileId,
mimeType: f.mimeType,
Expand Down Expand Up @@ -631,15 +631,7 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
folderOrFiles,
async (f): Promise<ContentNode> => {
const type = getPermissionViewType(f);
let sourceUrl = null;

if (isGoogleDriveSpreadSheetFile(f)) {
sourceUrl = `https://docs.google.com/spreadsheets/d/${f.driveFileId}/edit`;
} else if (isGoogleDriveFolder(f)) {
sourceUrl = `https://drive.google.com/drive/folders/${f.driveFileId}`;
} else {
sourceUrl = `https://drive.google.com/file/d/${f.driveFileId}/view`;
}
const sourceUrl = getSourceUrlForGoogleDriveFiles(f);

return {
provider: "google_drive",
Expand Down Expand Up @@ -963,3 +955,13 @@ async function getFoldersAsContentNodes({
{ concurrency: 4 }
);
}

function getSourceUrlForGoogleDriveFiles(f: GoogleDriveFiles): string {
if (isGoogleDriveSpreadSheetFile(f)) {
return `https://docs.google.com/spreadsheets/d/${f.driveFileId}/edit`;
} else if (isGoogleDriveFolder(f)) {
return `https://drive.google.com/drive/folders/${f.driveFileId}`;
}

return `https://drive.google.com/file/d/${f.driveFileId}/view`;
}

0 comments on commit 102e2bb

Please sign in to comment.