sklad: proper validations on container update

This commit is contained in:
Přemysl Eric Janouch 2019-04-22 13:56:08 +02:00
parent 88560a8fbf
commit 81927e9017
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -205,6 +205,13 @@ func dbContainerCreate(c *Container) error {
}
func dbContainerUpdate(c *Container, updated Container) error {
if _, ok := indexSeries[updated.Series]; !ok {
return errNoSuchSeries
}
if updated.Parent != "" && indexContainer[updated.Parent] == nil {
return errNoSuchContainer
}
newID := updated.Id()
if updated.Series != c.Series && len(c.Children()) > 0 {
return errCannotChangeSeriesNotEmpty