Make graph.Delta zero state invalid for use

Previously, an incorrectly initialised Delta (omission of Action) would
result in an Add operation. Make that detectable and return an error.
This commit is contained in:
kortschak 2015-01-27 08:39:50 +10:30
parent 9088fe376b
commit 46f987ca51
5 changed files with 20 additions and 5 deletions

View file

@ -185,6 +185,9 @@ func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta) error {
resizeMap := make(map[string]int64)
sizeChange := int64(0)
for _, d := range deltas {
if d.Action != graph.Add && d.Action != graph.Delete {
return errors.New("leveldb: invalid action")
}
bytes, err := json.Marshal(d)
if err != nil {
return err