From 5357e57ae75e550740c906372c38916e04e45306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Tue, 28 Sep 2021 00:41:32 +0200 Subject: [PATCH] keep data option --- src/FileSystemHandle.js | 1 + src/adapters/deno.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FileSystemHandle.js b/src/FileSystemHandle.js index 2bab58b..6d7976e 100644 --- a/src/FileSystemHandle.js +++ b/src/FileSystemHandle.js @@ -18,6 +18,7 @@ class FileSystemHandle { async queryPermission ({mode = 'read'} = {}) { const handle = this[kAdapter] + if (handle.queryPermission) { return handle.queryPermission({mode}) } diff --git a/src/adapters/deno.js b/src/adapters/deno.js index 01e3294..12296e9 100644 --- a/src/adapters/deno.js +++ b/src/adapters/deno.js @@ -116,11 +116,13 @@ export class FileHandle { return this.#path } - async createWritable () { - const fileHandle = await Deno.open(this.#path, {write: true}).catch(err => { + /** @param {{ keepExistingData: any; }} opts */ + async createWritable (opts) { + const fileHandle = await Deno.open(this.#path, { write: true, truncate: !opts.keepExistingData }).catch(err => { if (err.name === 'NotFound') throw new DOMException(...GONE) throw err }) + const { size } = await fileHandle.stat() return new Sink(fileHandle, size) }