Skip to content

Commit 0790c73

Browse files
committed
add extra check for listing empty directory
1 parent d414642 commit 0790c73

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jupyter_drives/manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ async def get_contents(self, drive_name, path):
218218

219219
# dealing with the case of an empty directory
220220
# TO DO: find better way to check
221-
if emptyDir is True and os.path.basename(path).find('.') == -1:
222-
data = []
221+
if emptyDir is True:
222+
ext_list = ['.R', '.bmp', '.csv', '.gif', '.html', '.ipynb', '.jl', '.jpeg', '.jpg', '.json', '.jsonl', '.md', '.ndjson', '.pdf', '.png', '.py', '.svg', '.tif', '.tiff', '.tsv', '.txt', '.webp', '.yaml', '.yml']
223+
object_name = os.path.basename(path)
224+
# if object doesn't contain . or doesn't end in one of the registered extensions
225+
if object_name.find('.') == -1 or ext_list.count(os.path.splitext(object_name)[1]) == 0:
226+
data = []
223227

224228
response = {
225229
"data": data

0 commit comments

Comments
 (0)