Skip to content

Commit

Permalink
$mol_file disabe verbose logs, fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Dec 18, 2024
1 parent 4a0d062 commit bb93e68
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
3 changes: 0 additions & 3 deletions build/ensure/ensure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ namespace $ {

@ $mol_mem_key
ensure( path : string ): boolean {
if (path.includes('/-/')) {
console.warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ensure build', new Error().stack)
}
const mod = $mol_file.absolute( path )
const parent = mod.parent()

Expand Down
22 changes: 8 additions & 14 deletions file/base/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace $ {
if (/([\/\\]\.|___$)/.test( path )) return

const file = this.relative( path.at(-1) === '/' ? path.slice(0, -1) : path )
console.log(type, path)
// console.log(type, path)

// add (change): добавился файл - у parent надо обновить список sub, если он был заюзан
// change, unlink (rename): обновился или удалился файл - ресетим
Expand Down Expand Up @@ -148,12 +148,6 @@ namespace $ {
с точки зрения реактивной системы hyoo/board еще не существует.
*/
this.changed.add(this.absolute(path))
// const stack = new Error().stack
// this.watch_wd = new $mol_after_timeout(10000, () => {
// console.error('Lock timeout')
// console.error(stack)
// })

}

// protected static watch_wd = null as null | $mol_after_timeout
Expand Down Expand Up @@ -187,37 +181,37 @@ namespace $ {
@ $mol_mem
version() {
const next = this.stat()?.mtime.getTime().toString( 36 ).toUpperCase() ?? ''
console.log('version', next, this.path())
// console.log('version', next, this.path())
return next
}

protected info( path: string ) { return null as null | $mol_file_stat }
protected ensure() {}
protected drop() {}
protected copy(to: string) {}
protected read() { return new Uint8Array }
protected write(buffer: Uint8Array) { }
protected read(): Uint8Array<ArrayBuffer> { return new Uint8Array }
protected write(buffer: Uint8Array<ArrayBuffer>) { }
protected kids() {
return [] as readonly this[]
}

@ $mol_mem_key
readable(opts: { start?: number, end?: number }) {
return new ReadableStream<Uint8Array>
return new ReadableStream<Uint8Array<ArrayBuffer>>
}

@ $mol_mem_key
writable(opts: { start?: number }) {
return new WritableStream<Uint8Array>
return new WritableStream<Uint8Array<ArrayBuffer>>
}

// open( ... modes: readonly $mol_file_mode[] ) { return 0 }

@ $mol_mem
buffer( next? : Uint8Array ): Uint8Array {
buffer( next? : Uint8Array<ArrayBuffer> ): Uint8Array<ArrayBuffer> {

// Если версия пустая - возвращаем пустой буфер
let readed = new Uint8Array
let readed: Uint8Array<ArrayBuffer> = new Uint8Array()

if( next === undefined ) {
// Если меняется версия файла, буфер надо перечитать
Expand Down
4 changes: 2 additions & 2 deletions file/file.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ namespace $ {
encoding: 'binary',
})

return Readable.toWeb(stream) as ReadableStream<Uint8Array>
return Readable.toWeb(stream) as ReadableStream<Uint8Array<ArrayBuffer>>
}

@ $mol_mem
Expand All @@ -225,7 +225,7 @@ namespace $ {
encoding: 'binary',
})

return Writable.toWeb(stream) as WritableStream<Uint8Array>
return Writable.toWeb(stream) as WritableStream<Uint8Array<ArrayBuffer>>
}

open( ... modes: readonly $mol_file_mode[] ) {
Expand Down
6 changes: 3 additions & 3 deletions file/webdav/webdav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace $ {
protected override read() {
try {
const response = this.fetch({})
return new Uint8Array(response.buffer())
return new Uint8Array(response.buffer()) as Uint8Array<ArrayBuffer>
} catch (error) {
if (
error instanceof Error
Expand All @@ -50,7 +50,7 @@ namespace $ {
}
}

protected override write( body : Uint8Array ) { this.fetch({ method: 'PUT', body }) }
protected override write( body : Uint8Array<ArrayBuffer> ) { this.fetch({ method: 'PUT', body }) }
protected override ensure() { this.fetch({ method: 'MKCOL' }) }
protected override drop() { this.fetch({ method: 'DELETE' }) }

Expand Down Expand Up @@ -94,7 +94,7 @@ namespace $ {
headers: ! opts.start ? {} : {
'Range': `bytes=${opts.start}-${opts.end ?? ''}`
}
}).stream() || $mol_fail(new Error('Not found'))
}).stream() as ReadableStream<Uint8Array<ArrayBuffer>> | null || $mol_fail(new Error('Not found'))
}

protected override info() {
Expand Down

0 comments on commit bb93e68

Please sign in to comment.