packages/content/lib/database.js
/**
   * Clear items in database and load files into collection
   */
Clear items in database and load files into collection
Clear items in database and load files into collection
async initFromFilesystem () {
    const startTime = process.hrtime()
    this.dirs = ['/']
    this.items.clear()
    if (this.options.ipfsRoot) {
      try {
        if (!client) {
          client = this.options.ipfsApiEndpoint ? create(this.options.ipfsApiEndpoint) : await ipfsCoreClient.create()
        }
        const root = await client.dag.get(CID.parse(this.options.ipfsRoot))
        if (root && root.value && root.value.Links.length > 0) {
          this.dirs = []
          await this.walkIpfs(client, '/ipfs', CID.parse(this.options.ipfsRoot))
        }
      } catch (e) {
        throw new Error(`ipfs api open fail ${this.options.ipfsApiEndpoint}/${e}`)
      }
    } else {
      await this.walk(this.dir)
    }
    const [s, ns] = process.hrtime(startTime)
    logger.info(`Parsed ${this.items.count()} files in ${s}.${Math.round(ns / 1e8)} seconds`)
  }
async initFromFilesystem ( ) { const startTime = process . hrtime ( ) this . dirs = [ '/' ] this . items . clear ( ) if ( this . options . ipfsRoot ) { try { if ( ! client ) { client = this . options . ipfsApiEndpoint ? create ( this . options . ipfsApiEndpoint ) : await ipfsCoreClient . create ( ) } const root = await client . dag . get ( CID . parse ( this . options . ipfsRoot ) ) if ( root && root . value && root . value . Links . length > 0 ) { this . dirs = [ ] await this . walkIpfs ( client , '/ipfs' , CID . parse ( this . options . ipfsRoot ) ) } } catch ( e ) { throw new Error ( ` ${ this . options . ipfsApiEndpoint } ${ e } ` ) } } else { await this . walk ( this . dir ) } const [ s , ns ] = process . hrtime ( startTime ) logger . info ( ` ${ this . items . count ( ) } ${ s } ${ Math . round ( ns / 1e8 ) } ` ) }
Clear items in database and load files into collection
Clear items in database and load files into collection