Skip to content

Commit

Permalink
fix with files
Browse files Browse the repository at this point in the history
  • Loading branch information
markus621 committed Feb 1, 2024
1 parent f71f2a6 commit 35381dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions encryption/pgp/pgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ func New() Signer {

func (v *store) SetKey(b []byte, passwd string) error {
r := bytes.NewReader(b)
return v.readKey(r, passwd)
if err := v.readKey(r, passwd); err != nil {
return err
}
return nil
}

func (v *store) SetHash(hash crypto.Hash, bits int) {
Expand All @@ -82,7 +85,11 @@ func (v *store) SetKeyFromFile(filename string, passwd string) error {
if err != nil {
return errors.Wrapf(err, "read key from file")
}
return v.readKey(r, passwd)
defer r.Close() //nolint: errcheck
if err = v.readKey(r, passwd); err != nil {
return err
}
return nil
}

func (v *store) PublicKey() ([]byte, error) {
Expand Down
6 changes: 3 additions & 3 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ replace (

require (
go.osspkg.com/goppy v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/app v0.3.0
go.osspkg.com/goppy/app v0.3.1
go.osspkg.com/goppy/auth v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/console v0.3.0
go.osspkg.com/goppy/geoip v0.0.0-00010101000000-000000000000
Expand All @@ -47,13 +47,13 @@ require (
go.osspkg.com/goppy/ormmysql v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/ormpgsql v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/ormsqlite v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/plugins v0.3.0
go.osspkg.com/goppy/plugins v0.3.1
go.osspkg.com/goppy/routine v0.3.0
go.osspkg.com/goppy/syscall v0.3.0
go.osspkg.com/goppy/tcp v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/udp v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/unixsocket v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/web v0.3.0
go.osspkg.com/goppy/web v0.3.1
go.osspkg.com/goppy/ws v0.0.0-00010101000000-000000000000
go.osspkg.com/goppy/xc v0.3.0
go.osspkg.com/goppy/xdns v0.0.0-00010101000000-000000000000
Expand Down
2 changes: 2 additions & 0 deletions iofile/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func IsValidHash(filename string, h hash.Hash, valid string) error {
if err != nil {
return err
}
defer r.Close() //nolint: errcheck
if _, err = io.Copy(h, r); err != nil {
return errors.Wrapf(err, "calculate file hash")
}
Expand All @@ -36,6 +37,7 @@ func Hash(filename string, h hash.Hash) (string, error) {
if err != nil {
return "", err
}
defer r.Close() //nolint: errcheck
if _, err = io.Copy(h, r); err != nil {
return "", errors.Wrapf(err, "calculate file hash")
}
Expand Down

0 comments on commit 35381dd

Please sign in to comment.