Commit d9fb9e7c authored by Joe Tsai's avatar Joe Tsai Committed by Joe Tsai

archive/tar: change error prefix

Change error message prefix from "tar:" to "archive/tar:" to maintain
backwards compatibility with Go1.9 and earlier in the unfortunate event
that someone is relying on string parsing of errors.

Fixes #22740

Change-Id: I59039c59818a0599e9d3b06bb5a531aa22a389b8
Reviewed-on: https://go-review.googlesource.com/77933Reviewed-by: 's avatarroger peppe <rogpeppe@gmail.com>
parent a265f2e9
......@@ -28,19 +28,19 @@ import (
// stored in Header will be the truncated version.
var (
ErrHeader = errors.New("tar: invalid tar header")
ErrWriteTooLong = errors.New("tar: write too long")
ErrFieldTooLong = errors.New("tar: header field too long")
ErrWriteAfterClose = errors.New("tar: write after close")
errMissData = errors.New("tar: sparse file references non-existent data")
errUnrefData = errors.New("tar: sparse file contains unreferenced data")
errWriteHole = errors.New("tar: write non-NUL byte in sparse hole")
ErrHeader = errors.New("archive/tar: invalid tar header")
ErrWriteTooLong = errors.New("archive/tar: write too long")
ErrFieldTooLong = errors.New("archive/tar: header field too long")
ErrWriteAfterClose = errors.New("archive/tar: write after close")
errMissData = errors.New("archive/tar: sparse file references non-existent data")
errUnrefData = errors.New("archive/tar: sparse file contains unreferenced data")
errWriteHole = errors.New("archive/tar: write non-NUL byte in sparse hole")
)
type headerError []string
func (he headerError) Error() string {
const prefix = "tar: cannot encode header"
const prefix = "archive/tar: cannot encode header"
var ss []string
for _, s := range he {
if s != "" {
......@@ -580,7 +580,7 @@ func (h *Header) PunchSparseHoles(f *os.File) (err error) {
size = h.SparseHoles[len(h.SparseHoles)-1].endOffset()
}
if !validateSparseEntries(h.SparseHoles, size) {
return errors.New("tar: invalid sparse holes")
return errors.New("archive/tar: invalid sparse holes")
}
if size == 0 {
......@@ -698,7 +698,7 @@ const (
// for sparse file support, additionally call Header.DetectSparseHoles.
func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) {
if fi == nil {
return nil, errors.New("tar: FileInfo is nil")
return nil, errors.New("archive/tar: FileInfo is nil")
}
fm := fi.Mode()
h := &Header{
......@@ -725,9 +725,9 @@ func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) {
case fm&os.ModeNamedPipe != 0:
h.Typeflag = TypeFifo
case fm&os.ModeSocket != 0:
return nil, fmt.Errorf("tar: sockets not supported")
return nil, fmt.Errorf("archive/tar: sockets not supported")
default:
return nil, fmt.Errorf("tar: unknown file mode %v", fm)
return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm)
}
if fm&os.ModeSetuid != 0 {
h.Mode |= c_ISUID
......
......@@ -53,7 +53,7 @@ func (tw *Writer) Flush() error {
return tw.err
}
if nb := tw.curr.LogicalRemaining(); nb > 0 {
return fmt.Errorf("tar: missed writing %d bytes", nb)
return fmt.Errorf("archive/tar: missed writing %d bytes", nb)
}
if _, tw.err = tw.w.Write(zeroBlock[:tw.pad]); tw.err != nil {
return tw.err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment