Update transcoder.go

This commit is contained in:
gongym
2020-08-25 13:38:05 +08:00
committed by GitHub
parent d910add319
commit aa6bff624d

View File

@@ -306,14 +306,16 @@ func (t Transcoder) Output() <-chan models.Progress {
if atEOF && len(data) == 0 {
return 0, nil, nil
}
if i := bytes.IndexByte(data, '\n'); i >= 0 {
// We have a full newline-terminated line.
return i + 1, data[0:i], nil
}
//windows \r\n
//so first \r and then \n can remove unexpected line break
if i := bytes.IndexByte(data, '\r'); i >= 0 {
// We have a cr terminated line
return i + 1, data[0:i], nil
}
if i := bytes.IndexByte(data, '\n'); i >= 0 {
// We have a full newline-terminated line.
return i + 1, data[0:i], nil
}
if atEOF {
return len(data), data, nil
}