Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions router/router_server_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (

// Data passed over to initiate a server transfer.
type serverTransferRequest struct {
URL string `binding:"required" json:"url"`
Token string `binding:"required" json:"token"`
Server installer.ServerDetails `json:"server"`
URL string `binding:"required" json:"url"`
Token string `binding:"required" json:"token"`
Backups []string `json:"backups"`
Server installer.ServerDetails `json:"server"`
}

// postServerTransfer handles the start of a transfer for a server.
Expand Down Expand Up @@ -80,7 +81,7 @@ func postServerTransfer(c *gin.Context) {
go func() {
defer transfer.Outgoing().Remove(trnsfr)

if _, err := trnsfr.PushArchiveToTarget(data.URL, data.Token); err != nil {
if _, err := trnsfr.PushArchiveToTarget(data.URL, data.Token, data.Backups); err != nil {
notifyPanelOfFailure()

if err == context.Canceled {
Expand Down
1 change: 1 addition & 0 deletions server/transfer/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (t *Transfer) Archive() (*Archive, error) {
}

func (a *Archive) StreamBackups(ctx context.Context, mp *multipart.Writer) error {
// In theory this can't happen as this function is only called if there at least is 1 backup but just to be sure
if len(a.transfer.BackupUUIDs) == 0 {
a.transfer.Log().Debug("no backups specified for transfer")
return nil
Expand Down
6 changes: 4 additions & 2 deletions server/transfer/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// PushArchiveToTarget POSTs the archive to the target node and returns the
// response body.
func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error) {
func (t *Transfer) PushArchiveToTarget(url, token string, backups []string) ([]byte, error) {
ctx, cancel := context.WithCancel(t.ctx)
defer cancel()

Expand All @@ -28,6 +28,7 @@ func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error) {
}

t.SendMessage("Streaming archive to destination...")


// Send the upload progress to the websocket every 5 seconds.
ctx2, cancel2 := context.WithCancel(ctx)
Expand Down Expand Up @@ -123,7 +124,8 @@ func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error) {
errChan <- errors.New("failed to stream main archive checksum")
return
}

// Store the UUID of the backups we want to transfer in the transfer struct
t.BackupUUIDs = backups
if len(t.BackupUUIDs) > 0 {
t.SendMessage(fmt.Sprintf("Streaming %d backup files to destination...", len(t.BackupUUIDs)))
if err := a.StreamBackups(ctx, mp); err != nil {
Expand Down
Loading