Betterbird's pinned .tar.xz failed on the build seat with "this build seat has no xz to read it": the seat's image is the catalogue's build-agent recipe, which installs git and docker-cli alone, and xz had been added only to cmd/mesh-builder/Dockerfile, which the seat does not build from. The stream is now read with github.com/ulikunitz/xz (vendored), its dictionary capped at xz's own largest preset, and what it unpacks to bounded as before; the xz line in the unused Dockerfile is taken back out.
41 lines
858 B
Go
41 lines
858 B
Go
// Copyright 2014-2022 Ulrich Kunitz. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package lzma
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
// breader provides the ReadByte function for a Reader. It doesn't read
|
|
// more data from the reader than absolutely necessary.
|
|
type breader struct {
|
|
io.Reader
|
|
// helper slice to save allocations
|
|
p []byte
|
|
}
|
|
|
|
// ByteReader converts an io.Reader into an io.ByteReader.
|
|
func ByteReader(r io.Reader) io.ByteReader {
|
|
br, ok := r.(io.ByteReader)
|
|
if !ok {
|
|
return &breader{r, make([]byte, 1)}
|
|
}
|
|
return br
|
|
}
|
|
|
|
// ReadByte read byte function.
|
|
func (r *breader) ReadByte() (c byte, err error) {
|
|
for i := 0; i < 100; i++ {
|
|
n, err := r.Reader.Read(r.p)
|
|
if n > 0 {
|
|
return r.p[0], nil
|
|
}
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return 0, io.ErrNoProgress
|
|
}
|