Skip to content
Open
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion jupyter_server/services/contents/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,12 @@ def _dir_model(self, path, content=True):
model = self._base_model(path)
model["type"] = "directory"
model["size"] = None
model["item_count"] = None
if content:
model["content"] = contents = []
os_dir = self._get_os_path(path)
dir_contents = os.listdir(os_dir)
model["item_count"] = len(dir_contents)
for name in os.listdir(os_dir):
try:
os_path = os.path.join(os_dir, name)
Expand Down Expand Up @@ -334,7 +337,6 @@ def _dir_model(self, path, content=True):
os_path,
exc_info=True,
)

model["format"] = "json"

return model
Expand Down Expand Up @@ -470,6 +472,7 @@ def _save_directory(self, os_path, model, path=""):
if not os.path.exists(os_path):
with self.perm_to_403():
os.mkdir(os_path)
model["item_count"] = 0
elif not os.path.isdir(os_path):
raise web.HTTPError(400, "Not a directory: %s" % (os_path))
else:
Expand Down Expand Up @@ -765,10 +768,12 @@ async def _dir_model(self, path, content=True):
model = self._base_model(path)
model["type"] = "directory"
model["size"] = None
model["item_count"] = None
if content:
model["content"] = contents = []
os_dir = self._get_os_path(path)
dir_contents = await run_sync(os.listdir, os_dir)
model["item_count"] = len(dir_contents)
for name in dir_contents:
try:
os_path = os.path.join(os_dir, name)
Expand Down
Loading