mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
Merge pull request #11 from xpzouying/zy/fix-remove-dup-close-db
fix: remove db twice
This commit is contained in:
commit
6fa84004b3
1 changed files with 3 additions and 2 deletions
5
cli.go
5
cli.go
|
@ -2,6 +2,7 @@ package headscale
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
|
@ -90,7 +91,7 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
|
|||
log.Printf("Cannot open DB: %s", err)
|
||||
return err
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
routes, _ := json.Marshal([]string{routeStr}) // TODO: only one for the time being, so overwriting the rest
|
||||
m.EnabledRoutes = postgres.Jsonb{RawMessage: json.RawMessage(routes)}
|
||||
db.Save(&m)
|
||||
|
@ -107,6 +108,6 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
|
|||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("Could not find routable range")
|
||||
|
||||
return errors.New("could not find routable range")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue