mirror of
https://github.com/Luzifer/tex-api.git
synced 2024-11-08 08:10:09 +00:00
Lint: Fix linter errors
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4937284b0e
commit
3364efc57b
3 changed files with 28 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/.default_env
|
||||
/.storage
|
||||
/fake-build.sh
|
||||
tex-api
|
||||
|
|
19
assets.go
19
assets.go
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/Luzifer/go_helpers/v2/str"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
)
|
||||
|
@ -43,11 +44,15 @@ func buildAssetsTAR(uid uuid.UUID) (io.Reader, error) {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "opening source file")
|
||||
}
|
||||
defer func() {
|
||||
if err := osFile.Close(); err != nil {
|
||||
logrus.WithError(err).Error("closing output file (leaked fd)")
|
||||
}
|
||||
}()
|
||||
|
||||
if _, err := io.Copy(w, osFile); err != nil {
|
||||
return errors.Wrap(err, "copying source file")
|
||||
}
|
||||
osFile.Close() // #nosec G104
|
||||
|
||||
return nil
|
||||
})
|
||||
|
@ -85,11 +90,15 @@ func buildAssetsZIP(uid uuid.UUID) (io.Reader, error) {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "opening source file")
|
||||
}
|
||||
defer func() {
|
||||
if err := osFile.Close(); err != nil {
|
||||
logrus.WithError(err).Error("closing output file (leaked fd)")
|
||||
}
|
||||
}()
|
||||
|
||||
if _, err := io.Copy(zipFile, osFile); err != nil {
|
||||
return errors.Wrap(err, "copying source file")
|
||||
}
|
||||
osFile.Close() // #nosec G104
|
||||
|
||||
return nil
|
||||
})
|
||||
|
@ -120,11 +129,15 @@ func getAssetsPDF(uid uuid.UUID) (io.Reader, error) {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "opening file")
|
||||
}
|
||||
defer func() {
|
||||
if err := osFile.Close(); err != nil {
|
||||
logrus.WithError(err).Error("closing output pdf file (leaked fd)")
|
||||
}
|
||||
}()
|
||||
|
||||
if _, err := io.Copy(buf, osFile); err != nil {
|
||||
return errors.Wrap(err, "reading file")
|
||||
}
|
||||
osFile.Close() // #nosec G104
|
||||
|
||||
found = true
|
||||
return filepath.SkipAll
|
||||
|
|
13
jobStatus.go
13
jobStatus.go
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/gofrs/uuid"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -59,7 +60,11 @@ func loadStatusByUUID(uid uuid.UUID) (*jobStatus, error) {
|
|||
if err != nil {
|
||||
return nil, errors.Wrap(err, "opening status file")
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
logrus.WithError(err).Error("closing status file (leaked fd)")
|
||||
}
|
||||
}()
|
||||
|
||||
if err = json.NewDecoder(f).Decode(&status); err != nil {
|
||||
return nil, errors.Wrap(err, "decoding status file")
|
||||
|
@ -79,7 +84,11 @@ func (s jobStatus) Save() error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "creating status file")
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
logrus.WithError(err).Error("closing status file (leaked fd)")
|
||||
}
|
||||
}()
|
||||
|
||||
if err = json.NewEncoder(f).Encode(s); err != nil {
|
||||
return errors.Wrap(err, "encoding status")
|
||||
|
|
Loading…
Reference in a new issue