Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jupyter_drives/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ async def mount_drive(self, drive_name, provider, location=''):
else:
region = await self._get_drive_location(drive_name)
self._initialize_content_manager(drive_name, provider, region)

# check if user is able to access drive
check = await self._file_system._exists(drive_name + '/')
if check is False:
raise Exception('Failed to mount drive. Access denied.')

except Exception as e:
raise tornado.web.HTTPError(
status_code= httpx.codes.BAD_REQUEST,
Expand Down
43 changes: 37 additions & 6 deletions src/plugins/driveBrowserPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
IToolbarWidgetRegistry,
setToolbar,
showDialog,
Dialog
Dialog,
Notification
} from '@jupyterlab/apputils';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import {
Expand All @@ -39,8 +40,9 @@ import { Widget } from '@lumino/widgets';

import { driveBrowserIcon, removeIcon } from '../icons';
import { Drive } from '../contents';
import { getContents, setListingLimit } from '../requests';
import { getContents, mountDrive, setListingLimit } from '../requests';
import { CommandIDs } from '../token';
import { DrivesResponseError } from '../handler';

/**
* Status bar widget for displaying drive information
Expand Down Expand Up @@ -535,9 +537,23 @@ namespace Private {
ariaLabel: 'Add Drive'
})
]
}).then(result => {
}).then(async result => {
if (result.value) {
drive.addPublicDrive(result.value);
const response = await mountDrive(result.value, {
provider: 's3'
});
if (response && response.error) {
// Show error in case of failure.
Notification.emit(
(response.error as DrivesResponseError).message,
'error',
{
autoClose: 5000
}
);
} else {
drive.addPublicDrive(result.value);
}
}
});
},
Expand Down Expand Up @@ -567,9 +583,24 @@ namespace Private {
ariaLabel: 'Add Drive'
})
]
}).then(result => {
}).then(async result => {
if (result.value) {
drive.addExternalDrive(result.value[0], result.value[1]);
const response = await mountDrive(result.value[0], {
provider: 's3',
location: result.value[1]
});
if (response && response.error) {
// Show error in case of failure.
Notification.emit(
(response.error as DrivesResponseError).message,
'error',
{
autoClose: 5000
}
);
} else {
drive.addExternalDrive(result.value[0], result.value[1]);
}
}
});
},
Expand Down
Loading