Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Rsync error msgs #58

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Changes from all commits
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
8 changes: 6 additions & 2 deletions cmd/coder/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -31,7 +32,8 @@ func (cmd *syncCmd) RegisterFlags(fl *pflag.FlagSet) {
}

// See https://lxadm.com/Rsync_exit_codes#List_of_standard_rsync_exit_codes.
var NoRsync = errors.New("rsync: exit status 2")
var IncompatRsync = errors.New("rsync: exit status 2")
var StreamErrRsync = errors.New("rsync: exit status 12")

func (cmd *syncCmd) Run(fl *pflag.FlagSet) {
var (
Expand Down Expand Up @@ -79,8 +81,10 @@ func (cmd *syncCmd) Run(fl *pflag.FlagSet) {
err = s.Run()
}

if err == NoRsync {
if fmt.Sprintf("%v", err) == fmt.Sprintf("%v", IncompatRsync) {
flog.Fatal("no compatible rsync present on remote machine")
} else if fmt.Sprintf("%v", err) == fmt.Sprintf("%v", StreamErrRsync) {
flog.Fatal("error in rsync protocol datastream (no installed remote rsync?)")
Comment on lines +84 to +87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't great.

We should be checking the exit code here, and wrap the error with an informative string based on the exit code.

See https://stackoverflow.com/a/55055100 for how we can get the exit code from a command error.

Copy link
Author

@Russtopia Russtopia Jun 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I figured this wasn't be best way to do it :/ I'll update this ASAP, and include it in PR #60

} else {
flog.Fatal("sync: %v", err)
}
Expand Down