Skip to content

Commit

Permalink
keep data option
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmywarting committed Sep 27, 2021
1 parent bb8e331 commit 5357e57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/FileSystemHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FileSystemHandle {

async queryPermission ({mode = 'read'} = {}) {
const handle = this[kAdapter]

if (handle.queryPermission) {
return handle.queryPermission({mode})
}
Expand Down
6 changes: 4 additions & 2 deletions src/adapters/deno.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 5357e57

Please sign in to comment.