##// END OF EJS Templates
s/open_w/atomic_writing/
Min RK -
Show More
@@ -57,7 +57,7 b' class FileContentsManager(ContentsManager):'
57 yield f
57 yield f
58
58
59 @contextmanager
59 @contextmanager
60 def open_w(self, os_path, *args, **kwargs):
60 def atomic_writing(self, os_path, *args, **kwargs):
61 """wrapper around atomic_writing that turns permission errors into 403"""
61 """wrapper around atomic_writing that turns permission errors into 403"""
62 with self.perm_to_403(os_path):
62 with self.perm_to_403(os_path):
63 with atomic_writing(os_path, *args, **kwargs) as f:
63 with atomic_writing(os_path, *args, **kwargs) as f:
@@ -358,7 +358,7 b' class FileContentsManager(ContentsManager):'
358
358
359 self.check_and_sign(nb, path)
359 self.check_and_sign(nb, path)
360
360
361 with self.open_w(os_path, encoding='utf-8') as f:
361 with self.atomic_writing(os_path, encoding='utf-8') as f:
362 nbformat.write(nb, f, version=nbformat.NO_CONVERT)
362 nbformat.write(nb, f, version=nbformat.NO_CONVERT)
363
363
364 def _save_file(self, os_path, model, path=''):
364 def _save_file(self, os_path, model, path=''):
@@ -375,7 +375,7 b' class FileContentsManager(ContentsManager):'
375 bcontent = base64.decodestring(b64_bytes)
375 bcontent = base64.decodestring(b64_bytes)
376 except Exception as e:
376 except Exception as e:
377 raise web.HTTPError(400, u'Encoding error saving %s: %s' % (os_path, e))
377 raise web.HTTPError(400, u'Encoding error saving %s: %s' % (os_path, e))
378 with self.open_w(os_path, text=False) as f:
378 with self.atomic_writing(os_path, text=False) as f:
379 f.write(bcontent)
379 f.write(bcontent)
380
380
381 def _save_directory(self, os_path, model, path=''):
381 def _save_directory(self, os_path, model, path=''):
General Comments 0
You need to be logged in to leave comments. Login now