mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-27 13:57:46 +00:00
Fix time.Time msgpack decoding backwards compatibility
See https://github.com/ugorji/go-codec/issues/269
This commit is contained in:
committed by
Andrey Smirnov
parent
5aefc741f2
commit
906cbf1e6f
@@ -696,6 +696,18 @@ func (repo *RemoteRepo) Decode(input []byte) error {
|
|||||||
repo.ReleaseFiles = repo11.ReleaseFiles
|
repo.ReleaseFiles = repo11.ReleaseFiles
|
||||||
repo.Filter = repo11.Filter
|
repo.Filter = repo11.Filter
|
||||||
repo.FilterWithDeps = repo11.FilterWithDeps
|
repo.FilterWithDeps = repo11.FilterWithDeps
|
||||||
|
} else if strings.Contains(err.Error(), "invalid length of bytes for decoding time") {
|
||||||
|
// DB created by old codec version, time.Time is not builtin type.
|
||||||
|
// https://github.com/ugorji/go-codec/issues/269
|
||||||
|
decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{
|
||||||
|
// only can be configured in Deprecated BasicHandle struct
|
||||||
|
BasicHandle: codec.BasicHandle{ // nolint: staticcheck
|
||||||
|
TimeNotBuiltin: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err = decoder.Decode(repo); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,18 @@ func (s *Snapshot) Decode(input []byte) error {
|
|||||||
s.SourceKind = snapshot11.SourceKind
|
s.SourceKind = snapshot11.SourceKind
|
||||||
s.SourceIDs = snapshot11.SourceIDs
|
s.SourceIDs = snapshot11.SourceIDs
|
||||||
s.Description = snapshot11.Description
|
s.Description = snapshot11.Description
|
||||||
|
} else if strings.Contains(err.Error(), "invalid length of bytes for decoding time") {
|
||||||
|
// DB created by old codec version, time.Time is not builtin type.
|
||||||
|
// https://github.com/ugorji/go-codec/issues/269
|
||||||
|
decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{
|
||||||
|
// only can be configured in Deprecated BasicHandle struct
|
||||||
|
BasicHandle: codec.BasicHandle{ // nolint: staticcheck
|
||||||
|
TimeNotBuiltin: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err = decoder.Decode(s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user