Skip to content

Commit

Permalink
use a generic RemoteInstruction in rclone struct for server side oper…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
l3uddz committed Apr 19, 2020
1 parent 55c666e commit 77a672c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
8 changes: 8 additions & 0 deletions rclone/rclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ var (
cfg *config.Configuration
)

/* Struct */

type RemoteInstruction struct {
From string
To string
ServerSide bool
}

/* Public */

func Init(c *config.Configuration) error {
Expand Down
10 changes: 2 additions & 8 deletions syncer/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ import (
"github.com/sirupsen/logrus"
)

type MoveInstruction struct {
From string
To string
ServerSide bool
}

func (s *Syncer) Move(additionalRcloneParams []string) error {
var moveRemotes []MoveInstruction
var moveRemotes []rclone.RemoteInstruction

// set variables
for _, remote := range s.Config.Remotes.MoveServerSide {
moveRemotes = append(moveRemotes, MoveInstruction{
moveRemotes = append(moveRemotes, rclone.RemoteInstruction{
From: remote.From,
To: remote.To,
ServerSide: true,
Expand Down
12 changes: 3 additions & 9 deletions uploader/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,15 @@ import (
"time"
)

type MoveInstruction struct {
From string
To string
ServerSide bool
}

func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error {
var moveRemotes []MoveInstruction
var moveRemotes []rclone.RemoteInstruction
var extraParams []string

// create move instructions
if serverSide {
// this is a server side move
for _, remote := range u.Config.Remotes.MoveServerSide {
moveRemotes = append(moveRemotes, MoveInstruction{
moveRemotes = append(moveRemotes, rclone.RemoteInstruction{
From: remote.From,
To: remote.To,
ServerSide: true,
Expand All @@ -35,7 +29,7 @@ func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error
extraParams = u.Config.RcloneParams.MoveServerSide
} else {
// this is a normal move (to only one location)
moveRemotes = append(moveRemotes, MoveInstruction{
moveRemotes = append(moveRemotes, rclone.RemoteInstruction{
From: u.Config.LocalFolder,
To: u.Config.Remotes.Move,
ServerSide: false,
Expand Down

0 comments on commit 77a672c

Please sign in to comment.