Skip to content

Commit

Permalink
fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
macdylan committed Sep 5, 2023
1 parent 2c99a44 commit 3cae5bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (p *Payload) ReadableSize() string {

func (p *Payload) GetContent(nofix bool) (cont []byte, err error) {
defer runtime.GC()
if nofix || !shouldBeFix(p.Name) {
if nofix || !p.ShouldBeFix() {
cont, err = io.ReadAll(p.File)
} else {
cont, err = postProcess(p.File)
Expand All @@ -43,6 +43,10 @@ func (p *Payload) GetContent(nofix bool) (cont []byte, err error) {
return cont, err
}

func (p *Payload) ShouldBeFix() bool {
return shouldBeFix(p.Name)
}

func NewPayload(file io.Reader, name string, size int64) *Payload {
return &Payload{
File: file,
Expand Down
2 changes: 1 addition & 1 deletion connector_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (hc *HTTPConnector) Upload(payload *Payload) (err error) {
log.SetOutput(os.Stderr)
if err != nil {
log.Printf("G-Code fix error(ignored): %s", err)
} else {
} else if payload.ShouldBeFix() {
log.Printf("G-Code fixed")
}
log.SetOutput(w)
Expand Down
2 changes: 1 addition & 1 deletion connector_sacp.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (sc *SACPConnector) Upload(payload *Payload) (err error) {
if !NoFix {
if err != nil {
log.Printf("G-Code fix error(ignored): %s", err)
} else {
} else if payload.ShouldBeFix() {
log.Printf("G-Code fixed")
}
}
Expand Down

0 comments on commit 3cae5bb

Please sign in to comment.