Skip to content

Commit

Permalink
Move a db query to db_images.go.
Browse files Browse the repository at this point in the history
Signed-off-by: René Jochum <rene@jochums.at>
  • Loading branch information
jochumdev committed Aug 11, 2015
1 parent 4e9b7e9 commit a6112e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 12 additions & 0 deletions lxd/db_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ import (
"github.com/lxc/lxd/shared"
)

func dbImageIDGet(db *sql.DB, fp string) int {
q := `SELECT id FROM images WHERE fingerprint=?`
id := -1
arg1 := []interface{}{fp}
arg2 := []interface{}{&id}
err := dbQueryRowScan(db, q, arg1, arg2)
if err != nil {
return -1
}
return id
}

func doImagesGet(d *Daemon, recursion bool, public bool) (interface{}, error) {
resultString := []string{}
resultMap := []shared.ImageInfo{}
Expand Down
14 changes: 1 addition & 13 deletions lxd/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,11 @@ func remoteGetImageFingerprint(d *Daemon, server string, alias string) (string,
return result.Name, nil
}

func (d *Daemon) dbGetimage(fp string) int {
q := `SELECT id FROM images WHERE fingerprint=?`
id := -1
arg1 := []interface{}{fp}
arg2 := []interface{}{&id}
err := dbQueryRowScan(d.db, q, arg1, arg2)
if err != nil {
return -1
}
return id
}

func ensureLocalImage(d *Daemon, server, fp string, secret string, forContainer bool) error {
var url string
var exporturl string

if d.dbGetimage(fp) != -1 {
if dbImageIDGet(d.db, fp) != -1 {
// already have it
return nil
}
Expand Down

0 comments on commit a6112e9

Please sign in to comment.