/**
 * A cache entry backed by a phz file.
 */ import { CacheEntry , DataCallback , ICacheEntry } from "./CacheEntry" ; import { PHZReader } from 'polar-content-capture/src/phz/PHZReader' ; import { Preconditions } from 'polar-shared/src/Preconditions' ; import { ResourceEntry } from 'polar-content-capture/src/phz/ResourceEntry' ; import { CompressedReader } from "polar-content-capture/src/phz/CompressedReader" ; export class PHZCacheEntry extends CacheEntry implements IPHZCacheEntry { public phzReader : CompressedReader ; public resourceEntry : ResourceEntry ; constructor ( opts ) { super ( opts ) ; this . phzReader = opts . phzReader ; this . resourceEntry = opts . resourceEntry ; Preconditions . assertNotNull ( this . phzReader , "phzReader" ) ; Preconditions . assertNotNull ( this . resourceEntry , "resourceEntry" ) ; Object . defineProperty ( this , 'phzReader' , { value : this . phzReader , enumerable : false } ) ; } public async handleData ( callback ) { const buffer = await this . phzReader . getResource ( this . resourceEntry ) ; callback ( buffer ) ; return false ; } public async toBuffer ( ) { return await this . phzReader . getResource ( this . resourceEntry ) ; } public async toStream ( ) { return await this . phzReader . getResourceAsStream ( this . resourceEntry ) ; } } export interface IPHZCacheEntry extends ICacheEntry { phzReader : CompressedReader ; resourceEntry : ResourceEntry ; }