From 36931f7a26da8d1d51cfbf646ad749a5dbaaa768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4ck?= Date: Fri, 22 Nov 2024 14:51:18 +0200 Subject: [PATCH] Don't attempt to list directories with public drive --- lib/strapi/search.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/strapi/search.ts b/lib/strapi/search.ts index 6587ca0..a685686 100644 --- a/lib/strapi/search.ts +++ b/lib/strapi/search.ts @@ -69,12 +69,14 @@ export const getDriveDirectories = async (): Promise => { 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