Пример #1
0
// fuseMountFolder uses the fuseklient library to mount the given
// folder.
func (m *Mounter) fuseMountFolder(mount *Mount) error {
	var (
		t   transport.Transport
		err error
	)

	t, err = transport.NewRemoteTransport(m.Transport, fuseTellTimeout, mount.RemotePath)
	if err != nil {
		return err
	}

	// user specifies to prefetch all content upfront
	if mount.PrefetchAll {
		dt, err := transport.NewDiskTransport(mount.CachePath)
		if err != nil {
			return err
		}

		// cast into RemoteTransport for NewDualTransport
		rt := t.(*transport.RemoteTransport)

		t = transport.NewDualTransport(rt, dt)
	}

	cf := &fuseklient.Config{
		Path:           mount.LocalPath,
		MountName:      mount.MountName,
		NoIgnore:       mount.NoIgnore,
		NoPrefetchMeta: mount.NoPrefetchMeta,
		NoWatch:        mount.NoWatch,
		Trace:          mount.Trace,
	}

	f, err := fuseklient.New(t, cf)
	if isRemotePathError(err) {
		return ErrRemotePathDoesNotExist
	} else if err != nil {
		return err
	}

	mount.MountedFS = f
	mount.Unmounter = f

	var fs *fuse.MountedFileSystem
	if fs, err = f.Mount(); err != nil {
		return err
	}

	// TODO: what context to use?
	go fs.Join(context.TODO())

	return nil
}
Пример #2
0
func newCachedTransport() (*transport.DualTransport, error) {
	rt, err := newRemoteTransport()
	if err != nil {
		return nil, err
	}

	dt, err := newDiskTransport()
	if err != nil {
		return nil, err
	}

	return transport.NewDualTransport(rt, dt), nil
}