small refactor*
This commit is contained in:
parent
b6b541e050
commit
24a4d30275
232 changed files with 2164 additions and 1906 deletions
13
plugins/rclone/go.mod
Normal file
13
plugins/rclone/go.mod
Normal file
|
@ -0,0 +1,13 @@
|
|||
module git.kmsign.ru/royalcat/tstor/plugins/rclone
|
||||
|
||||
go 1.23.5
|
||||
|
||||
require github.com/rclone/rclone v1.68.1
|
||||
|
||||
require (
|
||||
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/time v0.6.0 // indirect
|
||||
)
|
27
plugins/rclone/go.sum
Normal file
27
plugins/rclone/go.sum
Normal file
|
@ -0,0 +1,27 @@
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 h1:G+9t9cEtnC9jFiTxyptEKuNIAbiN5ZCQzX2a74lj3xg=
|
||||
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004/go.mod h1:KmHnJWQrgEvbuy0vcvj00gtMqbvNn1L+3YUZLK/B92c=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rclone/rclone v1.68.1 h1:vlEOAuPv4gGxWECM0NIaCwBNUt3ZQY7mCsyBtZjY+68=
|
||||
github.com/rclone/rclone v1.68.1/go.mod h1:T8XKOt/2Fb9INROUtFH9eF9q9o9rI1W2qTrW2bw2cYU=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
124
plugins/rclone/rclone.go
Normal file
124
plugins/rclone/rclone.go
Normal file
|
@ -0,0 +1,124 @@
|
|||
package rclone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/fs"
|
||||
"time"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
|
||||
rclonefs "github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
type fsWrapper struct {
|
||||
vfs.DefaultFS
|
||||
fs rclonefs.Fs
|
||||
}
|
||||
|
||||
// Open implements vfs.Filesystem.
|
||||
func (w *fsWrapper) Open(ctx context.Context, filename string) (vfs.File, error) {
|
||||
obj, err := w.fs.NewObject(ctx, filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &fileWrapper{name: filename, obj: obj}, nil
|
||||
}
|
||||
|
||||
// ReadDir implements vfs.Filesystem.
|
||||
func (w *fsWrapper) ReadDir(ctx context.Context, path string) ([]fs.DirEntry, error) {
|
||||
panic("unimplemented")
|
||||
|
||||
// path = vfs.RemoveTrailingSlash(path)
|
||||
|
||||
// entries, err := w.fs.List(ctx, path)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// out := make([]fs.DirEntry, 0, len(entries))
|
||||
// for _, e := range entries {
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// Rename implements vfs.Filesystem.
|
||||
func (f *fsWrapper) Rename(ctx context.Context, oldpath string, newpath string) error {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Stat implements vfs.Filesystem.
|
||||
func (f *fsWrapper) Stat(ctx context.Context, filename string) (fs.FileInfo, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Type implements vfs.Filesystem.
|
||||
// Subtle: this method shadows the method (DefaultFS).Type of fsWrapper.DefaultFS.
|
||||
func (f *fsWrapper) Type() fs.FileMode {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Unlink implements vfs.Filesystem.
|
||||
func (f *fsWrapper) Unlink(ctx context.Context, filename string) error {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
var _ vfs.Filesystem = (*fsWrapper)(nil)
|
||||
|
||||
type fileWrapper struct {
|
||||
name string
|
||||
obj rclonefs.Object
|
||||
}
|
||||
|
||||
var _ vfs.File = (*fileWrapper)(nil)
|
||||
|
||||
// Close implements vfs.File.
|
||||
func (f *fileWrapper) Close(ctx context.Context) error {
|
||||
return f.Close(ctx)
|
||||
}
|
||||
|
||||
// Info implements vfs.File.
|
||||
func (f *fileWrapper) Info() (fs.FileInfo, error) {
|
||||
return vfs.NewFileInfo(f.name, f.Size(), time.Time{}), nil
|
||||
}
|
||||
|
||||
// IsDir implements vfs.File.
|
||||
func (f *fileWrapper) IsDir() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Name implements vfs.File.
|
||||
func (f *fileWrapper) Name() string {
|
||||
return f.name
|
||||
}
|
||||
|
||||
// Read implements vfs.File.
|
||||
func (f *fileWrapper) Read(ctx context.Context, p []byte) (n int, err error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Seek implements vfs.File.
|
||||
func (f *fileWrapper) Seek(offset int64, whence int) (int64, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// ReadAt implements vfs.File.
|
||||
func (f *fileWrapper) ReadAt(ctx context.Context, p []byte, off int64) (n int, err error) {
|
||||
rc, err := f.obj.Open(ctx, &rclonefs.RangeOption{Start: off, End: off + int64(len(p))})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
return rc.Read(p)
|
||||
}
|
||||
|
||||
// Size implements vfs.File.
|
||||
func (f *fileWrapper) Size() int64 {
|
||||
return f.Size()
|
||||
}
|
||||
|
||||
// Type implements vfs.File.
|
||||
func (f *fileWrapper) Type() fs.FileMode {
|
||||
return vfs.ModeFileRO
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue