瀏覽代碼

Improve file browser state restoration error handling.

Afshin Darian 8 年之前
父節點
當前提交
759a1eeabd
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/filebrowser/plugin.ts

+ 6 - 2
src/filebrowser/plugin.ts

@@ -143,9 +143,13 @@ function activateFileBrowser(app: JupyterLab, manager: IServiceManager, registry
   });
 
   // Restore the state of the file browser on reload.
-  Promise.all([state.fetch(`${NAMESPACE}:cwd`), app.started]).then(([cwd]) => {
+  let key = `${NAMESPACE}:cwd`;
+  Promise.all([state.fetch(key), app.started, manager.ready]).then(([cwd]) => {
     if (cwd) {
-      fbModel.cd((cwd as any).path);
+      let path = cwd['path'] as string;
+      manager.contents.get(path)
+        .then(() => { fbModel.cd(path); })
+        .catch(() => { state.remove(key); });
     }
   });