Skip to content

Commit

Permalink
add a workaround of partition name
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Dec 10, 2020
1 parent 7502937 commit 2e724e8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
35 changes: 29 additions & 6 deletions core/commands/storage/path/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"unsafe"

"github.com/TRON-US/go-btfs-cmds"

"github.com/dustin/go-humanize"
logging "github.com/ipfs/go-log"
"github.com/mitchellh/go-homedir"
Expand Down Expand Up @@ -302,19 +303,27 @@ var PathPartitionsCmd = &cmds.Command{
if err != nil {
return err
}
return cmds.EmitOnce(res, stringList{Strings: ps})
return cmds.EmitOnce(res, ps)
},
Type: stringList{},
Type: []partition{},
}

func partitions() ([]string, error) {
var ps []string
infos, err := disk.Partitions(false)
type partition struct {
Name string `json:"name"`
MountPoint string `json:"mount_point"`
}

func partitions() ([]*partition, error) {
var ps []*partition
infos, err := disk.Partitions(true)
if err != nil {
return nil, err
}
for _, info := range infos {
ps = append(ps, info.Mountpoint)
ps = append(ps, &partition{
Name: info.Device,
MountPoint: info.Mountpoint,
})
}
return ps, nil
}
Expand Down Expand Up @@ -379,6 +388,20 @@ func WriteProperties() error {
return err
}

type Storage struct {
Name string
FileSystem string
Total uint64
Free uint64
}

type storageInfo struct {
Name string
Size uint64
FreeSpace uint64
FileSystem string
}

func MoveFolder() error {
err := os.Rename(OriginPath, StorePath)
// src and dest dir are not in the same partition
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require (
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6
github.com/TRON-US/go-btfs-api v0.3.0
github.com/TRON-US/go-btfs-chunker v0.3.0
github.com/TRON-US/go-btfs-cmds v0.2.7
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ github.com/TRON-US/go-btfs-files v0.2.0 h1:JZ+F0gX8iPmUf1OlrdOdsA8GMGxCHhwQ03jEW
github.com/TRON-US/go-btfs-files v0.2.0/go.mod h1:Qx+rTOIC0xl3ZkosGcEoB4hqExZmTONErPys8K5suEc=
github.com/TRON-US/go-btfs-pinner v0.1.1 h1:cqI3oGLfqoCCNjTGFoFt4Saq9JG2gLQNXiROukjJZQU=
github.com/TRON-US/go-btfs-pinner v0.1.1/go.mod h1:4CVxKEQNNTbuW92BIYwiH9/W63eDNtlt7bK0fCnXSag=
github.com/TRON-US/go-btns v0.1.0/go.mod h1:DQiF1iCxhDWUv5wWKueipXgi+D0PmkrRToO0btEOQ4k=
github.com/TRON-US/go-btns v0.1.1 h1:19rUEc9QK5aIz5Z278lQh6omXbQ3Ha40ecQX1DnGnT8=
github.com/TRON-US/go-btns v0.1.1/go.mod h1:PWfgUinn65Xzar61xNunkadza7h+v+cYFCOXpuVsixY=
github.com/TRON-US/go-car v0.3.0 h1:7SS9O8YFqWjy9zh7iB6QxUGimSSqVeQrNjBtts9zKWI=
github.com/TRON-US/go-car v0.3.0/go.mod h1:xVssqSpge7YwGmn8mxvIN4mjq5WRB4iVIY5suuVVrVE=
github.com/TRON-US/go-cid v0.3.0 h1:qVqgOU/aRzJoqRRbMoedIcurPD0CUsFXGcbZrKYgjRo=
Expand Down

0 comments on commit 2e724e8

Please sign in to comment.