Skip to content

Commit

Permalink
close database correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Aug 8, 2018
1 parent debc403 commit 7af2402
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/main/src/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ func Run() (err error) {
r.GET("/view/analysis/:family", func(c *gin.Context) {
family := c.Param("family")
d, err := database.Open(family, true)
defer d.Close()
if err != nil {
c.String(200, err.Error())
return
}
locationList, err := d.GetLocations()
d.Close()
if err != nil {
logger.Log.Warn("could not get locations")
c.String(200, err.Error())
Expand Down Expand Up @@ -148,9 +148,9 @@ func Run() (err error) {
var sensors []models.SensorData
var message string
db, err := database.Open(c.Param("family"), true)
defer db.Close()
if err == nil {
sensors, err = db.GetAllForClassification()
db.Close()
}
if err != nil {
message = err.Error()
Expand Down

0 comments on commit 7af2402

Please sign in to comment.