mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #4427 from minrk/checkpoint-on-first-save
notebooks should always have one checkpoint closes #4396
This commit is contained in:
commit
c3e6e625a7
@ -222,6 +222,10 @@ class FileNotebookManager(NotebookManager):
|
||||
|
||||
if 'content' not in model:
|
||||
raise web.HTTPError(400, u'No notebook JSON data provided')
|
||||
|
||||
# One checkpoint should always exist
|
||||
if self.notebook_exists(name, path) and not self.list_checkpoints(name, path):
|
||||
self.create_checkpoint(name, path)
|
||||
|
||||
new_path = model.get('path', path).strip('/')
|
||||
new_name = model.get('name', name)
|
||||
@ -326,8 +330,9 @@ class FileNotebookManager(NotebookManager):
|
||||
def get_checkpoint_path(self, checkpoint_id, name, path=''):
|
||||
"""find the path to a checkpoint"""
|
||||
path = path.strip('/')
|
||||
basename, _ = os.path.splitext(name)
|
||||
filename = u"{name}-{checkpoint_id}{ext}".format(
|
||||
name=name,
|
||||
name=basename,
|
||||
checkpoint_id=checkpoint_id,
|
||||
ext=self.filename_ext,
|
||||
)
|
||||
|
@ -117,7 +117,7 @@ class NotebookManager(LoggingConfigurable):
|
||||
raise NotImplementedError('must be implemented in a subclass')
|
||||
|
||||
def create_notebook_model(self, model=None, path=''):
|
||||
"""Create a new untitled notebook and return its model with no content."""
|
||||
"""Create a new notebook and return its model with no content."""
|
||||
path = path.strip('/')
|
||||
if model is None:
|
||||
model = {}
|
||||
|
Loading…
Reference in New Issue
Block a user