new rclone package
parent
be2a031834
commit
db72d59589
|
|
@ -1,6 +1,7 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"local/args"
|
||||
"local/logb"
|
||||
|
|
@ -9,7 +10,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ncw/rclone/fs/config"
|
||||
"github.com/rclone/rclone/fs/config"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -95,8 +96,8 @@ func Refresh() error {
|
|||
RCloneConfig = as.Get("rcconf").GetString()
|
||||
|
||||
os.Setenv("RCLONE_CONFIG", RCloneConfig)
|
||||
config.ConfigPath = RCloneConfig
|
||||
config.LoadConfig()
|
||||
config.SetConfigPath(RCloneConfig)
|
||||
config.LoadConfig(context.Background())
|
||||
|
||||
MonitorInterval = as.Get("interval").GetDuration()
|
||||
DryRun = as.Get("dry").GetBool()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package rclone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"local/logb"
|
||||
|
|
@ -8,21 +9,25 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
_ "github.com/ncw/rclone/backend/drive"
|
||||
_ "github.com/ncw/rclone/backend/local"
|
||||
_ "github.com/ncw/rclone/backend/s3"
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/fs/object"
|
||||
_ "github.com/rclone/rclone/backend/drive"
|
||||
_ "github.com/rclone/rclone/backend/local"
|
||||
_ "github.com/rclone/rclone/backend/s3"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/object"
|
||||
)
|
||||
|
||||
func (rc *RClone) Context() context.Context {
|
||||
return context.Background()
|
||||
}
|
||||
|
||||
func (rc *RClone) CopyTo(r io.Reader, destination string) error {
|
||||
logb.Verbosef("copy to: %v", destination)
|
||||
f, err := fs.NewFs(path.Dir(destination))
|
||||
f, err := fs.NewFs(rc.Context(), path.Dir(destination))
|
||||
logb.Verbosef("got new fs: %v", err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info, err := f.NewObject(path.Base(destination)); err == nil {
|
||||
if info, err := f.NewObject(rc.Context(), path.Base(destination)); err == nil {
|
||||
logb.Warnf("not re-uploading file to: %v: %v", destination, info)
|
||||
fmt.Println("copyTo", 3)
|
||||
return nil
|
||||
|
|
@ -36,21 +41,21 @@ func (rc *RClone) CopyTo(r io.Reader, destination string) error {
|
|||
logb.Debugf("copy to", info)
|
||||
//return nil TODO
|
||||
}
|
||||
_, err = f.Put(r, info)
|
||||
_, err = f.Put(rc.Context(), r, info)
|
||||
return err
|
||||
}
|
||||
|
||||
func (rc *RClone) CopyFrom(w io.Writer, source string) error {
|
||||
logb.Infof("copying from %v", source)
|
||||
f, err := fs.NewFs(path.Dir(source))
|
||||
f, err := fs.NewFs(rc.Context(), path.Dir(source))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
obj, err := f.NewObject(path.Base(source))
|
||||
obj, err := f.NewObject(rc.Context(), path.Base(source))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := obj.Open()
|
||||
r, err := obj.Open(rc.Context())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@ import (
|
|||
"local/sandbox/arlo-cleaner/config"
|
||||
"path"
|
||||
|
||||
_ "github.com/ncw/rclone/backend/drive"
|
||||
_ "github.com/ncw/rclone/backend/local"
|
||||
_ "github.com/ncw/rclone/backend/s3"
|
||||
"github.com/ncw/rclone/fs"
|
||||
_ "github.com/rclone/rclone/backend/drive"
|
||||
_ "github.com/rclone/rclone/backend/local"
|
||||
_ "github.com/rclone/rclone/backend/s3"
|
||||
"github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
func (rc *RClone) Del(destination string) error {
|
||||
f, err := fs.NewFs(path.Dir(destination))
|
||||
f, err := fs.NewFs(rc.Context(), path.Dir(destination))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
obj, err := f.NewObject(path.Base(destination))
|
||||
obj, err := f.NewObject(rc.Context(), path.Base(destination))
|
||||
if err == fs.ErrorObjectNotFound {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
|
@ -27,5 +27,5 @@ func (rc *RClone) Del(destination string) error {
|
|||
//return nil TODO
|
||||
}
|
||||
logb.Infof("removing %v", destination)
|
||||
return obj.Remove()
|
||||
return obj.Remove(rc.Context())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
package rclone
|
||||
|
||||
import (
|
||||
_ "github.com/ncw/rclone/backend/drive"
|
||||
_ "github.com/ncw/rclone/backend/local"
|
||||
_ "github.com/ncw/rclone/backend/s3"
|
||||
"github.com/ncw/rclone/fs"
|
||||
_ "github.com/rclone/rclone/backend/drive"
|
||||
_ "github.com/rclone/rclone/backend/local"
|
||||
_ "github.com/rclone/rclone/backend/s3"
|
||||
"github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
func (rc *RClone) List(destination string) ([]string, error) {
|
||||
f, err := fs.NewFs(destination)
|
||||
f, err := fs.NewFs(rc.Context(), destination)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
entries, err := f.List("")
|
||||
entries, err := f.List(rc.Context(), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package rclone
|
||||
|
||||
import (
|
||||
_ "github.com/ncw/rclone/backend/drive"
|
||||
_ "github.com/ncw/rclone/backend/local"
|
||||
_ "github.com/ncw/rclone/backend/s3"
|
||||
_ "github.com/rclone/rclone/backend/drive"
|
||||
_ "github.com/rclone/rclone/backend/local"
|
||||
_ "github.com/rclone/rclone/backend/s3"
|
||||
)
|
||||
|
||||
type RClone struct{}
|
||||
|
|
|
|||
Loading…
Reference in New Issue