Skip to content

Commit

Permalink
Fix time.Time msgpack decoding backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
zhsj committed Apr 13, 2019
1 parent 56c4d5b commit fca9f2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deb/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ func (repo *RemoteRepo) Decode(input []byte) error {
repo.ReleaseFiles = repo11.ReleaseFiles
repo.Filter = repo11.Filter
repo.FilterWithDeps = repo11.FilterWithDeps
} else if strings.Contains(err.Error(), "invalid length of bytes for decoding time") {
decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{
BasicHandle: codec.BasicHandle{TimeNotBuiltin: true},
})
if err := decoder.Decode(repo); err != nil {
return err
}
} else {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions deb/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ func (s *Snapshot) Decode(input []byte) error {
s.SourceKind = snapshot11.SourceKind
s.SourceIDs = snapshot11.SourceIDs
s.Description = snapshot11.Description
} else if strings.Contains(err.Error(), "invalid length of bytes for decoding time") {
decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{
BasicHandle: codec.BasicHandle{TimeNotBuiltin: true},
})
if err := decoder.Decode(s); err != nil {
return err
}
} else {
return err
}
Expand Down

0 comments on commit fca9f2c

Please sign in to comment.