aboutsummaryrefslogtreecommitdiffstats
path: root/commands/select/select.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/select/select.go')
-rw-r--r--commands/select/select.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/commands/select/select.go b/commands/select/select.go
index 694d636a..cd12250e 100644
--- a/commands/select/select.go
+++ b/commands/select/select.go
@@ -3,7 +3,6 @@ package _select
import (
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
@@ -101,6 +100,7 @@ func Select(repo *cache.RepoCache, namespace string, id entity.Id) error {
_, err = f.Write([]byte(id.String()))
if err != nil {
+ _ = f.Close()
return err
}
@@ -124,11 +124,18 @@ func selected[CacheT cache.CacheEntity](repo *cache.RepoCache, resolver Resolver
}
}
- buf, err := ioutil.ReadAll(io.LimitReader(f, 100))
+ buf, err := io.ReadAll(io.LimitReader(f, 100))
if err != nil {
+ _ = f.Close()
return nil, err
}
- if len(buf) == 100 {
+
+ err = f.Close()
+ if err != nil {
+ return nil, err
+ }
+
+ if len(buf) >= 100 {
return nil, fmt.Errorf("the select file should be < 100 bytes")
}
@@ -147,10 +154,5 @@ func selected[CacheT cache.CacheEntity](repo *cache.RepoCache, resolver Resolver
return nil, err
}
- err = f.Close()
- if err != nil {
- return nil, err
- }
-
return &cached, nil
}