Skip to content

Commit bdba3c8

Browse files
committed
Implement delete
1 parent d6b32f6 commit bdba3c8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/drive.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export class FileSystemDrive implements Contents.IDrive {
163163
let localPath = PathExt.basename(path);
164164
const name = localPath;
165165

166+
let data: Contents.IModel;
166167
if (type === 'directory') {
167168
let i = 1;
168169
while (await this.hasHandle(parentHandle, localPath)) {
@@ -171,7 +172,7 @@ export class FileSystemDrive implements Contents.IDrive {
171172

172173
await parentHandle.getDirectoryHandle(localPath, { create: true });
173174

174-
return this.get(PathExt.join(parentPath, localPath));
175+
data = await this.get(PathExt.join(parentPath, localPath));
175176
} else {
176177
let i = 1;
177178
while (await this.hasHandle(parentHandle, `${localPath}.${ext}`)) {
@@ -182,12 +183,28 @@ export class FileSystemDrive implements Contents.IDrive {
182183

183184
await parentHandle.getFileHandle(filename, { create: true });
184185

185-
return this.get(PathExt.join(parentPath, filename));
186+
data = await this.get(PathExt.join(parentPath, filename));
186187
}
188+
189+
this._fileChanged.emit({
190+
type: 'new',
191+
oldValue: null,
192+
newValue: data
193+
});
194+
195+
return data;
187196
}
188197

189-
delete(path: string): Promise<void> {
190-
throw new Error('Method not implemented.');
198+
async delete(path: string): Promise<void> {
199+
const parentHandle = await this.getParentHandle(path);
200+
201+
await parentHandle.removeEntry(PathExt.basename(path), { recursive: true });
202+
203+
this._fileChanged.emit({
204+
type: 'delete',
205+
oldValue: { path: path },
206+
newValue: null
207+
});
191208
}
192209

193210
rename(oldPath: string, newPath: string): Promise<Contents.IModel> {

0 commit comments

Comments
 (0)