Exemple #1
0
  engine.on('ready', function () {
    if (engine.torrent.name === (engine.files[0] && engine.files[0].path)) {
      var dir = engine.torrent.name.replace(/\.[^.]+$/, '')
      engine.torrent.files.forEach(function (file) {
        file.path = path.join(dir, file.path)
      })
      engine.torrent.name = dir
    }

    mnt = path.join(mnt, path.resolve('/', engine.torrent.name))
    fuse.unmount(mnt, function () {
      mkdirp(mnt, function () {
        fuse.mount(mnt, handlers)
        engine.emit('mount', mnt)
      })
    })

    if (!isLazy) {
      engine.files.forEach(function (file) {
        file.path = file.path.slice(engine.torrent.name.length + 1)
        file.select()
      })
    }

    engine.on('uninterested', function () {
      engine.swarm.pause()
    })

    engine.on('interested', function () {
      engine.swarm.resume()
    })
  })
Exemple #2
0
  requestHeaders(href, function (err, statusCode, headers) {
    if (err) return cb(new Error('HTTP Error ' + statusCode))

    if (!headers['accept-ranges'] || headers['accept-ranges'] !== 'bytes') {
      debug('range not supported', headers, statusCode)
      return cb(new Error('The HTTP server supplied doesnt support accept-ranges: bytes, so mount-url wont work for this url, sorry.'))
    }

    var len = headers['content-length']

    if (!len) len = 4096
    else len = +len
  
    file = {length: len, headers: headers}
    debug('file', file)
  
    fuse.unmount(mnt, function () {
      mkdirp(mnt, function () {
        fuse.mount(mnt, handlers, function (err) {
          if (err) {
            cleanup(function () {
              cb(new Error('Mount error: ' + err.message))
            })
            return
          }
          fs.symlink(path.join(mnt, filename), path.join(process.cwd(), filename), function (err) {
            if (err) {
              cleanup(function () {
                cb(new Error('Symlink error: ' + err.message))
              })
              return
            }
            cb(null, cleanup)
          })
        })
      })
    })
  })
Exemple #3
0
process.on('SIGINT', function () {
  fuse.unmount('test', function () {
    process.exit()
  })
})
Exemple #4
0
Mount.prototype.unmount = function(cb) {
  fuse.unmount(this.options.mountDir, cb)
}
Exemple #5
0
const fuse = require('fuse-bindings')
fuse.unmount('./mnt', function () {
  process.exit()
})
Exemple #6
0
 fs.unlink(path.join(process.cwd(), filename), function (err) {
   fuse.unmount(mnt, function () {
     if (cb) cb()
   })
 })
Exemple #7
0
process.on('SIGINT', function() {
    fuse.unmount(mntDir, function() {
        process.exit();
    });
});