File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,17 @@ export class FileSystemDrive implements Contents.IDrive {
42
42
const root = this . _rootHandle ;
43
43
44
44
if ( ! root ) {
45
- throw new Error ( 'Files not available' ) ;
45
+ return {
46
+ name : '' ,
47
+ path : '' ,
48
+ created : new Date ( ) . toISOString ( ) ,
49
+ last_modified : new Date ( ) . toISOString ( ) ,
50
+ format : 'json' ,
51
+ content : null ,
52
+ writable : true ,
53
+ type : 'directory' ,
54
+ mimetype : 'application/json'
55
+ } ;
46
56
}
47
57
48
58
if ( localPath ) {
@@ -123,11 +133,22 @@ export class FileSystemDrive implements Contents.IDrive {
123
133
throw new Error ( 'Method not implemented.' ) ;
124
134
}
125
135
126
- save (
136
+ async save (
127
137
localPath : string ,
128
138
options ?: Partial < Contents . IModel >
129
139
) : Promise < Contents . IModel > {
130
- throw new Error ( 'Method not implemented.' ) ;
140
+ const root = this . _rootHandle ;
141
+
142
+ if ( ! root ) {
143
+ throw new Error ( 'No root file handle' ) ;
144
+ }
145
+
146
+ const handle = await root . getFileHandle ( localPath ) ;
147
+ const writable = await handle . createWritable ( { } ) ;
148
+ const content = options ?. content ;
149
+ await writable . write ( content ) ;
150
+ await writable . close ( ) ;
151
+ return this . get ( localPath ) ;
131
152
}
132
153
133
154
copy ( localPath : string , toLocalDir : string ) : Promise < Contents . IModel > {
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ const plugin: JupyterFrontEndPlugin<void> = {
27
27
) => {
28
28
if ( ! window . showDirectoryPicker ) {
29
29
// bail if the browser does not support the File System API
30
- console . warn ( 'The File System API is not supported in this browser.' ) ;
30
+ console . warn (
31
+ 'The File System Access API is not supported in this browser.'
32
+ ) ;
31
33
return ;
32
34
}
33
35
You can’t perform that action at this time.
0 commit comments