Skip to content

Commit

Permalink
add --no-upload flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kovetskiy committed Jan 10, 2020
1 parent ed1e994 commit 981925b
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Advanced options:
[default: 16].
--no-preserve-uid Do not preserve UIDs for transferred files.
--no-preserve-gid Do not preserve GIDs for transferred files.
--no-upload Do not upload files while syncing.
Output format and colors options:
--json Output everything in line-by-line JSON format,
Expand Down Expand Up @@ -235,9 +236,7 @@ var (
statusbar *barely.StatusBar
)

var (
exit = os.Exit
)
var exit = os.Exit

func main() {
args := parseArgs()
Expand Down Expand Up @@ -434,6 +433,8 @@ func handleSynchronize(args map[string]interface{}) error {
serial = args["--serial"].(bool)

fileSources = args["<files>"].([]string)

noUpload = args["--no-upload"].(bool)
)

var (
Expand All @@ -442,18 +443,20 @@ func handleSynchronize(args map[string]interface{}) error {
err error
)

if !lockOnly {
debugf(`building files list from %d sources`, len(fileSources))
filesList, err = getFilesList(relative, fileSources...)
if err != nil {
return hierr.Errorf(
err,
`can't build files list`,
)
}
if !noUpload {
if !lockOnly {
debugf(`building files list from %d sources`, len(fileSources))
filesList, err = getFilesList(relative, fileSources...)
if err != nil {
return hierr.Errorf(
err,
`can't build files list`,
)
}

debugf(`file list contains %d files`, len(filesList))
tracef(`files to upload: %+v`, filesList)
debugf(`file list contains %d files`, len(filesList))
tracef(`files to upload: %+v`, filesList)
}
}

canceler := sync.NewCond(&sync.Mutex{})
Expand All @@ -473,15 +476,17 @@ func handleSynchronize(args map[string]interface{}) error {
return nil
}

err = upload(args, cluster, filesList)
if err != nil {
return hierr.Errorf(
err,
`can't upload files on the remote nodes`,
)
}
if !noUpload {
err = upload(args, cluster, filesList)
if err != nil {
return hierr.Errorf(
err,
`can't upload files on the remote nodes`,
)
}

tracef(`upload done`)
tracef(`upload done`)
}

if uploadOnly {
return nil
Expand Down Expand Up @@ -741,9 +746,7 @@ func parseAddresses(
defaultUser string,
fromStdin bool,
) ([]address, error) {
var (
hostsToParse = []string{}
)
hostsToParse := []string{}

if fromStdin {
scanner := bufio.NewScanner(os.Stdin)
Expand Down

0 comments on commit 981925b

Please sign in to comment.