From 81927e9017deb911d5d52461317bfad8a0b14406 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch
Date: Mon, 22 Apr 2019 13:56:08 +0200 Subject: sklad: proper validations on container update --- cmd/sklad/db.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cmd') diff --git a/cmd/sklad/db.go b/cmd/sklad/db.go index b58a5f2..fc79f0f 100644 --- a/cmd/sklad/db.go +++ b/cmd/sklad/db.go @@ -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 -- cgit v1.2.3-70-g09d2