Quellcode durchsuchen

Improve file browser state restoration error handling.

Afshin Darian vor 8 Jahren
Ursprung
Commit
759a1eeabd
1 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen
  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); });
     }
   });