From a4321ccf5a9bd6ea76d92a26581e00ff2e5a6372 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 9 Mar 2015 09:40:15 -0700 Subject: [PATCH 1/2] Get /files/ unmodified from contents request raw files instead of parsing notebooks avoids reserializing (inconsistently) on download of notebooks. --- IPython/html/files/handlers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IPython/html/files/handlers.py b/IPython/html/files/handlers.py index e78374edd..17c222d37 100644 --- a/IPython/html/files/handlers.py +++ b/IPython/html/files/handlers.py @@ -28,12 +28,12 @@ class FilesHandler(IPythonHandler): else: name = path - model = cm.get(path) + model = cm.get(path, type='file') if self.get_argument("download", False): self.set_header('Content-Disposition','attachment; filename="%s"' % name) - if model['type'] == 'notebook': + if model['type'] == 'notebook' or name.endswith('.ipynb'): self.set_header('Content-Type', 'application/json') else: cur_mime = mimetypes.guess_type(name)[0] From 91cf4ba39412455a47d030bd122772659e32375a Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 13 Mar 2015 12:23:07 -0700 Subject: [PATCH 2/2] get mime from filename remove never-true `type: notebook` case --- IPython/html/files/handlers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IPython/html/files/handlers.py b/IPython/html/files/handlers.py index 17c222d37..7727d084d 100644 --- a/IPython/html/files/handlers.py +++ b/IPython/html/files/handlers.py @@ -33,7 +33,8 @@ class FilesHandler(IPythonHandler): if self.get_argument("download", False): self.set_header('Content-Disposition','attachment; filename="%s"' % name) - if model['type'] == 'notebook' or name.endswith('.ipynb'): + # get mimetype from filename + if name.endswith('.ipynb'): self.set_header('Content-Type', 'application/json') else: cur_mime = mimetypes.guess_type(name)[0]