зеркало из https://github.com/mozilla/mig.git
[minor] fix keyring io.Reader copy in api
This commit is contained in:
Родитель
78bdc51c69
Коммит
06fd4c86a1
|
@ -6,9 +6,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"code.google.com/p/gcfg"
|
"code.google.com/p/gcfg"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"mig"
|
"mig"
|
||||||
migdb "mig/database"
|
migdb "mig/database"
|
||||||
"mig/pgp"
|
"mig/pgp"
|
||||||
|
@ -193,7 +195,7 @@ func makeKeyring() (keyring io.ReadSeeker, err error) {
|
||||||
|
|
||||||
// getKeyring copy an io.Reader from the master keyring. If the keyring hasn't been refreshed
|
// getKeyring copy an io.Reader from the master keyring. If the keyring hasn't been refreshed
|
||||||
// in a while, it also gets a fresh copy from the database
|
// in a while, it also gets a fresh copy from the database
|
||||||
func getKeyring() (kr io.ReadSeeker, err error) {
|
func getKeyring() (kr io.Reader, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if e := recover(); e != nil {
|
if e := recover(); e != nil {
|
||||||
err = fmt.Errorf("getKeyring() -> %v", e)
|
err = fmt.Errorf("getKeyring() -> %v", e)
|
||||||
|
@ -207,11 +209,17 @@ func getKeyring() (kr io.ReadSeeker, err error) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ctx.Keyring.UpdateTime = time.Now()
|
ctx.Keyring.UpdateTime = time.Now()
|
||||||
|
} else {
|
||||||
|
// rewind the master keyring
|
||||||
|
_, err = ctx.Keyring.Reader.Seek(0, 0)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_, err = ctx.Keyring.Reader.Seek(0, 0)
|
buf, err := ioutil.ReadAll(ctx.Keyring.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
kr = ctx.Keyring.Reader
|
kr = bytes.NewBuffer(buf)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче