dat-fs

1.0.0 • Public • Published

dat-fs

  • create/resume a .dat folder database.
  • import files using hyperdrive-import-files

API

var datFs = DatFs(dir)

Initialize datFs with your Dat repo directory. The directory is where the .dat folder will be and the files will be imported from.

datFs.db(opts, cb)

Read or create the .dat folder database.

Use the callback to create your drive and archive:

datFs.db({}, function (err, db, key, updateDbKey) {
  var archive
  var drive = hyperdrive(db)
 
  if (key) {
    // Resuming existing archive
    archive = drive.createArchive(key) 
    return done()
  } else {
    // Creating new
    archive = drive.createArchive()
    updateDbKey(archive.key, done) // Save the new key to db so you can resume
  }
})

var importer = datFs.importFiles(archive, opts, cb)

Where importer is hyperdrive-import-files. The only difference is that datFs counts directory size first so you can calculate importing progress.

(TODO: doc rest of count/import API)

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i dat-fs

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jhand