Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit223551b

Browse files
committed
Update local, remote version checks to avoid blanks.
1 parent54cecb2 commit223551b

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

‎cmd/coder/sync.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package main
22

33
import (
4-
"bufio"
5-
"errors"
4+
"bytes"
65
"fmt"
76
"log"
87
"os"
@@ -34,32 +33,18 @@ func (cmd *syncCmd) RegisterFlags(fl *pflag.FlagSet) {
3433
fl.BoolVarP(&cmd.init,"init","i",false,"do initial transfer and exit")
3534
}
3635

37-
// See https://lxadm.com/Rsync_exit_codes#List_of_standard_rsync_exit_codes.
38-
varIncompatRsync=errors.New("rsync: exit status 2")
39-
varStreamErrRsync=errors.New("rsync: exit status 12")
40-
4136
// Returns local rsync protocol version as a string.
42-
func(s*syncCmd)version()string {
37+
funcversion()string {
4338
cmd:=exec.Command("rsync","--version")
44-
stdout,err:=cmd.StdoutPipe()
39+
out,err:=cmd.CombinedOutput()
4540
iferr!=nil {
4641
log.Fatal(err)
4742
}
4843

49-
iferr:=cmd.Start();err!=nil {
50-
log.Fatal(err)
51-
}
52-
53-
r:=bufio.NewReader(stdout)
54-
iferr:=cmd.Wait();err!=nil {
55-
log.Fatal(err)
56-
}
57-
58-
firstLine,err:=r.ReadString('\n')
44+
firstLine,err:=bytes.NewBuffer(out).ReadString('\n')
5945
iferr!=nil {
60-
return""
46+
log.Fatal(err)
6147
}
62-
6348
versionString:=strings.Split(firstLine,"protocol version ")
6449

6550
returnversionString[1]

‎internal/sync/sync.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sync
22

33
import (
4-
"bufio"
4+
"bytes"
55
"context"
66
"errors"
77
"fmt"
@@ -283,7 +283,8 @@ func (s Sync) Version() (string, error) {
283283
iferr!=nil {
284284
return"",err
285285
}
286-
r:=bufio.NewReader(process.Stdout())
286+
buf:=&bytes.Buffer{}
287+
goio.Copy(buf,process.Stdout())
287288

288289
err=process.Wait()
289290
ifcode,ok:=err.(wsep.ExitError);ok {
@@ -293,7 +294,7 @@ func (s Sync) Version() (string, error) {
293294
return"",fmt.Errorf("Server version mismatch")
294295
}
295296

296-
firstLine,err:=r.ReadString('\n')
297+
firstLine,err:=buf.ReadString('\n')
297298
iferr!=nil {
298299
return"",err
299300
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp