Skip to content
Merged
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
8 changes: 8 additions & 0 deletions jupyter_server_documents/rooms/yroom_file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def __init__(self, *args, **kwargs):
self._last_path = None
self._last_modified = None
self._stopped = False
self._is_writable = True

# Initialize content-related primitives
self._content_loading = False
Expand Down Expand Up @@ -199,6 +200,10 @@ async def _load_content(self, jupyter_ydoc: YBaseDoc) -> None:
format=self.file_format
))

# The content manager uses this to tell consumers of the API if the file is writable.
# We need to save this so we can use it during save.
self._is_writable = file_data.get('writable', True)

if self.file_type == "notebook":
self.log.info(f"Processing outputs for loaded notebook: '{self.room_id}'.")
file_data = self.outputs_manager.process_loaded_notebook(file_id=self.file_id, file_data=file_data)
Expand Down Expand Up @@ -364,6 +369,9 @@ async def save(self, jupyter_ydoc: YBaseDoc):
instead.
"""
try:
# Return immediately if the content manager has marked this file as non-writable
if not self._is_writable:
return
# Build arguments to `CM.save()`
path = self.get_path()
content = jupyter_ydoc.source
Expand Down
Loading