Skip to content

Commit

Permalink
Last modified timestamp of a paired notebook is that of the file last…
Browse files Browse the repository at this point in the history
… written

Fix #207
  • Loading branch information
mwouts committed Mar 25, 2019
1 parent 4c9077b commit bc72eb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions jupytext/contentsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def save(self, model, path=''):

# Save as ipynb first
return_value = None
value = None
for fmt in jupytext_formats[::-1]:
if fmt['extension'] != '.ipynb':
continue
Expand Down Expand Up @@ -267,6 +268,8 @@ def save(self, model, path=''):
if alt_path == path:
return_value = value

# Update modified timestamp to match that of the pair #207
return_value['last_modified'] = value['last_modified']
return return_value

except Exception as err:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_contentsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ def test_share_py_recreate_ipynb(tmpdir, nb_file):
cm.default_cell_metadata_filter = "-all"

nb = readf(nb_file)
cm.save(model=dict(content=nb, type='notebook'), path='nb.ipynb')
model_ipynb = cm.save(model=dict(content=nb, type='notebook'), path='nb.ipynb')

assert os.path.isfile(tmp_ipynb)
assert os.path.isfile(tmp_py)
Expand All @@ -1134,3 +1134,6 @@ def test_share_py_recreate_ipynb(tmpdir, nb_file):

# ipynb is re-created
assert os.path.isfile(tmp_ipynb)

# save time of ipynb is that of py file
assert model_ipynb['last_modified'] == model['last_modified']

0 comments on commit bc72eb3

Please sign in to comment.