1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00

Empty result handling, and err checking

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
Riyaz Faizullabhoy
2016-04-06 10:14:27 -07:00
parent 6ace616c34
commit 01a988a817

View File

@@ -116,7 +116,7 @@ func (rdb RethinkDB) UpdateCurrent(gun string, update MetaUpdate) error {
Conflict: "error", // default but explicit for clarity of intent
},
).RunWrite(rdb.sess)
if gorethink.IsConflictErr(err) {
if err != nil && gorethink.IsConflictErr(err) {
return &ErrOldVersion{}
}
return err
@@ -155,6 +155,9 @@ func (rdb RethinkDB) GetCurrent(gun, role string) (created *time.Time, data []by
return nil, nil, ErrNotFound{}
}
err = res.One(&file)
if err == gorethink.ErrEmptyResult {
return nil, nil, ErrNotFound{}
}
return &file.CreatedAt, file.Data, err
}
@@ -177,6 +180,9 @@ func (rdb RethinkDB) GetChecksum(gun, role, checksum string) (created *time.Time
return nil, nil, ErrNotFound{}
}
err = res.One(&file)
if err == gorethink.ErrEmptyResult {
return nil, nil, ErrNotFound{}
}
return &file.CreatedAt, file.Data, err
}