2 Commits
Author SHA1 Message Date
sugoidogo a1838bc153 fix missing file close
Release / release (push) Successful in 23s
2026-02-15 18:48:28 -08:00
sugoidogo 65e8e64079 cleaner file implementation
Release / release (push) Successful in 23s
2026-02-09 13:41:04 -08:00
2 changed files with 5 additions and 7 deletions
+4 -7
View File
@@ -9,7 +9,7 @@ import type {
FileSystemGetFileOptions,
FileSystemCreateWritableOptions,
FileSystemWritableFileStream,
File
File as WebFile
} from '@sugoidogo/importable-types-web'
export default class NodeFileSystemFileHandle extends NodeFileSystemHandle implements FileSystemFileHandle {
@@ -24,13 +24,10 @@ export default class NodeFileSystemFileHandle extends NodeFileSystemHandle imple
async createWritable(options: FileSystemCreateWritableOptions = {}): Promise<FileSystemWritableFileStream> {
return new NodeFileSystemWritableFileStream(this.path,options)
}
async getFile(): Promise<File> {
async getFile(): Promise<WebFile> {
const stats = await asyncfs.stat(this.path)
const type = mime.getType(this.name.split('.').pop())
return asyncfs.readFile(this.path).then(buffer => Object.assign(new Blob([buffer], { type }), {
lastModified: stats.mtimeMs,
name: this.path,
webkitRelativePath: this.path
})) as unknown as File // TODO ArrayBufferView and DataView are incompatible types
const buffer = await asyncfs.readFile(this.path)
return new File([buffer], this.path, { "lastModified": stats.mtimeMs, "type": type }) as any //TODO Node File and Web File have some incompatibilities
}
}
+1
View File
@@ -39,6 +39,7 @@ export default class NodeFileSystemWritableFileStream extends WritableStream imp
}
const file = await asyncfs.open(this.#name,'r+')
await file.write((wdata as Uint8Array), null, wsize, this.#seek_position)
await file.close()
this.#seek_position = pseek_position
}
}