Skip to content

Commit 3092f5e

Browse files
committed
update mount function and error handling for external drives
1 parent 8b7939c commit 3092f5e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

jupyter_drives/manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ async def mount_drive(self, drive_name, provider, location=''):
319319
else:
320320
region = await self._get_drive_location(drive_name)
321321
self._initialize_content_manager(drive_name, provider, region)
322+
323+
# check if user is able to access drive
324+
check = await self._file_system._exists(drive_name + '/')
325+
if check is False:
326+
raise Exception('Failed to mount drive. Access denied.')
327+
322328
except Exception as e:
323329
raise tornado.web.HTTPError(
324330
status_code= httpx.codes.BAD_REQUEST,

src/plugins/driveBrowserPlugin.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,24 @@ namespace Private {
583583
ariaLabel: 'Add Drive'
584584
})
585585
]
586-
}).then(result => {
586+
}).then(async result => {
587587
if (result.value) {
588-
drive.addExternalDrive(result.value[0], result.value[1]);
588+
const response = await mountDrive(result.value[0], {
589+
provider: 's3',
590+
location: result.value[1]
591+
});
592+
if (response && response.error) {
593+
// Show error in case of failure.
594+
Notification.emit(
595+
(response.error as DrivesResponseError).message,
596+
'error',
597+
{
598+
autoClose: 5000
599+
}
600+
);
601+
} else {
602+
drive.addExternalDrive(result.value[0], result.value[1]);
603+
}
589604
}
590605
});
591606
},

0 commit comments

Comments
 (0)