Skip to content

Commit a495f6c

Browse files
authored
Merge pull request #95 from DenisaCG/fix_add_external_drive
Update mount function to allow optional location parameter
2 parents 72099a2 + 160adec commit a495f6c

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

jupyter_drives/manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,17 @@ async def list_drives(self):
303303
}
304304
return response
305305

306-
async def mount_drive(self, drive_name, provider):
306+
async def mount_drive(self, drive_name, provider, location=''):
307307
"""Mount a drive.
308308
309309
Args:
310310
drive_name: name of drive to mount
311311
"""
312312
try:
313313
if provider == 's3':
314-
if drive_name in self._external_drives and self._external_drives[drive_name]["is_public"] is False:
314+
if location:
315+
region = location
316+
elif drive_name in self._external_drives and self._external_drives[drive_name]["is_public"] is False:
315317
region = self._external_drives[drive_name]["location"]
316318
else:
317319
region = await self._get_drive_location(drive_name)

src/plugins/drivelistmanager.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ export function DriveInputComponent({
6868
<input
6969
type="checkbox"
7070
checked={isPublic}
71-
onChange={event => setIsPublic(event.target.checked)}
71+
onChange={event => {
72+
setIsPublic(event.target.checked);
73+
setRegion('');
74+
}}
7275
/>
7376
{!isPublic && (
7477
<input
@@ -212,7 +215,8 @@ export function DriveListManagerComponent({ model }: IProps) {
212215
const onAddedPublicDrive = async () => {
213216
// Check if user has access to drive.
214217
const result = await mountDrive(publicDrive, {
215-
provider: 's3'
218+
provider: 's3',
219+
location: driveRegion
216220
});
217221
if (result && result.error) {
218222
// Show error in case of failure.
@@ -223,9 +227,10 @@ export function DriveListManagerComponent({ model }: IProps) {
223227
await addPublicDrive(publicDrive);
224228
} else {
225229
await addExternalDrive(publicDrive, driveRegion);
226-
setDriveRegion('');
227230
}
231+
setPublicDrive('');
228232
setDriveRegion('');
233+
setIsPublic(false);
229234
await model.refresh();
230235
}
231236
};

src/requests.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ export async function getDrivesList() {
6767
*/
6868
export async function mountDrive(
6969
driveName: string,
70-
options: { provider: string }
70+
options: { provider: string; location?: string }
7171
) {
7272
const body: ReadonlyJSONObject = {
7373
drive_name: driveName,
74-
provider: options.provider
74+
provider: options.provider,
75+
location: options.location ?? ''
7576
};
7677
try {
7778
await requestAPI<any>('drives', 'POST', body);

0 commit comments

Comments
 (0)