From: Shengjing Zhu Date: Sat, 13 Apr 2019 22:57:46 +0800 Subject: Fix time.Time msgpack decoding backwards compatibility This allows aptly to decode DB created by old codec library. Forwarded: https://github.com/aptly-dev/aptly/pull/830 --- deb/remote.go | 3 ++- deb/snapshot.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) Index: aptly/deb/remote.go =================================================================== --- aptly.orig/deb/remote.go +++ aptly/deb/remote.go @@ -688,7 +688,8 @@ func (repo *RemoteRepo) Decode(input []b decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{}) err := decoder.Decode(repo) if err != nil { - if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") { + if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") || + strings.Contains(err.Error(), "invalid length of bytes for decoding time") { // probably it is broken DB from go < 1.2, try decoding w/o time.Time var repo11 struct { // nolint: maligned UUID string Index: aptly/deb/snapshot.go =================================================================== --- aptly.orig/deb/snapshot.go +++ aptly/deb/snapshot.go @@ -152,7 +152,8 @@ func (s *Snapshot) Decode(input []byte) decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{}) err := decoder.Decode(s) if err != nil { - if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") { + if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") || + strings.Contains(err.Error(), "invalid length of bytes for decoding time") { // probably it is broken DB from go < 1.2, try decoding w/o time.Time var snapshot11 struct { UUID string