forked from keybase/client
/
kbfs_mount.go
50 lines (41 loc) · 1.31 KB
/
kbfs_mount.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package service
import (
"golang.org/x/net/context"
"github.com/keybase/client/go/libkb"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
)
type KBFSMountHandler struct {
*BaseHandler
libkb.Contextified
}
func NewKBFSMountHandler(xp rpc.Transporter, g *libkb.GlobalContext) *KBFSMountHandler {
return &KBFSMountHandler{
BaseHandler: NewBaseHandler(g, xp),
Contextified: libkb.NewContextified(g),
}
}
func (h *KBFSMountHandler) GetCurrentMountDir(ctx context.Context) (res string, err error) {
drive, err := h.G().Env.GetMountDir()
if drive != "" && err == nil {
// Drive icon repairman: RemoteSettingsRepairman forgot about this, so let's set
// the registry again here for a few releases
libkb.ChangeMountIcon("", drive)
}
return drive, err
}
func (h *KBFSMountHandler) GetAllAvailableMountDirs(ctx context.Context) (res []string, err error) {
return getMountDirs()
}
func (h *KBFSMountHandler) SetCurrentMountDir(_ context.Context, drive string) (err error) {
oldMount, _ := h.G().Env.GetMountDir()
w := h.G().Env.GetConfigWriter()
err = w.SetStringAtPath("mountdir", drive)
if err != nil {
return err
}
h.G().ConfigReload()
libkb.ChangeMountIcon(oldMount, drive)
return nil
}