Skip to content

Commit

Permalink
Merge pull request #83 from Teknologforeningen/drive-directory-bugfix
Browse files Browse the repository at this point in the history
Don't attempt to list directories with public drive
  • Loading branch information
backjonas authored Nov 22, 2024
2 parents 7fe2321 + 36931f7 commit 2ad7567
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/strapi/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ export const getDriveDirectories =
async (): Promise<drive_v3.Schema$FileList | null> => {
try {
const session = await getServerSession(authOptions)
const drive = session && session.user ? privateDrive : publicDrive
if (!session?.user) {
return null
}

if (!drive) {
if (!privateDrive) {
throw new Error('Drive instance is not available')
}
return drive.getAllDirectories()
return privateDrive.getAllDirectories()
} catch (err) {
console.error('Error searching files:', err)
return null
Expand Down

0 comments on commit 2ad7567

Please sign in to comment.