浏览代码

return correct length in ReadFrom

v2ray 9 年之前
父节点
当前提交
2c82f65189
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      common/io/buffered_writer.go

+ 1 - 1
common/io/buffered_writer.go

@@ -33,13 +33,13 @@ func (this *BufferedWriter) ReadFrom(reader io.Reader) (int64, error) {
 	totalBytes := int64(0)
 	for {
 		nBytes, err := this.buffer.FillFrom(reader)
+		totalBytes += int64(nBytes)
 		if err != nil {
 			if err == io.EOF {
 				return totalBytes, nil
 			}
 			return totalBytes, err
 		}
-		totalBytes += int64(nBytes)
 		this.FlushWithoutLock()
 	}
 }