rclone: first commit

This commit is contained in:
mkvolkov 2022-08-18 11:44:33 +03:00
parent 2a70f2bb2d
commit c04f83af6a
4 changed files with 808 additions and 5 deletions

11
go.mod
View File

@ -3,11 +3,12 @@ module github.com/spf13/afero
require ( require (
cloud.google.com/go/storage v1.14.0 cloud.google.com/go/storage v1.14.0
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8
github.com/pkg/sftp v1.13.1 github.com/pkg/sftp v1.13.5-0.20211228200725-31aac3e1878d
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa github.com/rclone/rclone v1.59.1 // indirect
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99 golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/text v0.3.4 golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb
google.golang.org/api v0.40.0 golang.org/x/text v0.3.7
google.golang.org/api v0.83.0
) )
go 1.16 go 1.16

741
go.sum

File diff suppressed because it is too large Load Diff

51
rclonefs/fs.go Normal file
View File

@ -0,0 +1,51 @@
package rclonefs
import (
"context"
"fmt"
"os/user"
"path/filepath"
"strings"
_ "github.com/rclone/rclone/backend/all"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config"
"github.com/rclone/rclone/fs/config/configfile"
"github.com/rclone/rclone/vfs"
)
type RCFS struct {
Fs *vfs.VFS
Cwd string
}
func (rcfs *RCFS) CreateRCFS(path string) (*RCFS, error) {
u, e := user.Current()
if e != nil {
return nil, e
}
cfgpath := filepath.Join(u.HomeDir, ".config/rclone/rclone.conf")
e = config.SetConfigPath(cfgpath)
if e != nil {
return nil, e
}
configfile.Install()
rootdir, cwd, _ := strings.Cut(path, ":")
rootdir += ":"
rfs, e := fs.NewFs(context.Background(), rootdir)
if e != nil {
return nil, e
}
vfs := vfs.New(rfs, nil)
data, _ := vfs.ReadFile("mock.json")
fmt.Printf("%s\n", string(data))
return &RCFS{Fs: vfs, Cwd: cwd}, nil
}

10
rclonetest/main.go Normal file
View File

@ -0,0 +1,10 @@
package main
import (
"github.com/spf13/afero"
"github.com/spf13/afero/rclonefs"
)
func main() {
newrc := rclonefs.CreateRCFS("godrive_mv1:")
}