From 3645dd7d01e33daedf2b75aa5d44b803f2c45d46 Mon Sep 17 00:00:00 2001 From: Emmm Monster <58943012+emmmx@users.noreply.github.com> Date: Tue, 25 May 2021 04:36:32 +0800 Subject: [PATCH] fix: remove test file --- src/shims-fs.d.ts | 9 ++++++++- src/view/Home.vue | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/shims-fs.d.ts b/src/shims-fs.d.ts index d128aae..c7ae721 100644 --- a/src/shims-fs.d.ts +++ b/src/shims-fs.d.ts @@ -6,6 +6,10 @@ interface FileSystemCreateWritableOptions { keepExistingData?: boolean } +interface FileSystemRemoveOptions { + recursive?: boolean +} + interface FileSystemFileHandle { getFile(): Promise; @@ -37,13 +41,16 @@ interface FileSystemWritableFileStream extends WritableStream { close(): Promise // should be implemented in WritableStream } + export declare interface FileSystemDirectoryHandle { getFileHandle(name: string, options?: FileSystemGetFileOptions): Promise + + removeEntry(name: string, options?: FileSystemRemoveOptions): Promise + } declare global { interface Window { - FileSystemDirectoryHandle showDirectoryPicker?(): Promise } diff --git a/src/view/Home.vue b/src/view/Home.vue index 6f4e2b8..a337c59 100644 --- a/src/view/Home.vue +++ b/src/view/Home.vue @@ -144,9 +144,9 @@ export default { } try { this.dir = await window.showDirectoryPicker() - window.dir = this.dir - window.f = await this.dir.getFileHandle("write-test.txt", {create: true}) - + const test_filename = "__unlock_music_write_test.txt" + await this.dir.getFileHandle(test_filename, {create: true}) + await this.dir.removeEntry(test_filename) } catch (e) { console.error(e) }