mirror of https://github.com/perkeep/perkeep.git
cmd/...: fix staticcheck warnings
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com> Signed-off-by: Brad Fitzpatrick <brad@danga.com>
This commit is contained in:
parent
45f873a1c8
commit
8bb27e4b34
|
@ -379,6 +379,8 @@ func (up *Uploader) uploadNode(ctx context.Context, n *node) (*client.PutResult,
|
|||
}
|
||||
bb := schema.NewCommonFileMap(n.fullPath, fi)
|
||||
switch {
|
||||
default:
|
||||
return nil, fmt.Errorf("pk-put.files: unsupported file type %v for file %v", mode, n.fullPath)
|
||||
case mode&os.ModeSymlink != 0:
|
||||
// TODO(bradfitz): use VFS here; not os.Readlink
|
||||
target, err := os.Readlink(n.fullPath)
|
||||
|
@ -393,8 +395,6 @@ func (up *Uploader) uploadNode(ctx context.Context, n *node) (*client.PutResult,
|
|||
bb.SetType(schema.TypeSocket)
|
||||
case mode&os.ModeNamedPipe != 0: // fifo
|
||||
bb.SetType(schema.TypeFIFO)
|
||||
default:
|
||||
return nil, fmt.Errorf("pk-put.files: unsupported file type %v for file %v", mode, n.fullPath)
|
||||
case fi.IsDir():
|
||||
ss, err := n.directoryStaticSet()
|
||||
if err != nil {
|
||||
|
|
|
@ -66,7 +66,7 @@ func (c *initCmd) Usage() {
|
|||
for _, v := range c.usageExamples() {
|
||||
usage += v + "\n"
|
||||
}
|
||||
fmt.Fprintf(cmdmain.Stderr, usage)
|
||||
fmt.Fprint(cmdmain.Stderr, usage)
|
||||
}
|
||||
|
||||
func (c *initCmd) usageExamples() []string {
|
||||
|
|
|
@ -116,9 +116,6 @@ func (c *KvHaveCache) StatBlobCache(br blob.Ref) (size uint32, ok bool) {
|
|||
if err != nil {
|
||||
log.Fatalf("Could not decode have cache binary value for %v: %v", br, err)
|
||||
}
|
||||
if val < 0 {
|
||||
log.Fatalf("Error decoding have cache binary value for %v: size=%d", br, val)
|
||||
}
|
||||
cachelog.Printf("have cache HIT on %v", br)
|
||||
return uint32(val), true
|
||||
}
|
||||
|
@ -127,11 +124,8 @@ func (c *KvHaveCache) NoteBlobExists(br blob.Ref, size uint32) {
|
|||
if !br.Valid() {
|
||||
return
|
||||
}
|
||||
if size < 0 {
|
||||
log.Fatalf("Got a negative blob size to note in have cache for %v", br)
|
||||
}
|
||||
binBr, _ := br.MarshalBinary()
|
||||
binVal := []byte(strconv.Itoa(int(size)))
|
||||
binVal := fmt.Appendf(nil, "%d", size)
|
||||
cachelog.Printf("Adding to have cache %v: %q", br, binVal)
|
||||
if err := c.db.Put(binBr, binVal, nil); err != nil {
|
||||
log.Fatalf("Could not write %v in have cache: %v", br, err)
|
||||
|
@ -181,6 +175,9 @@ func (c *KvStatCache) CachedPutResult(pwd, filename string, fi os.FileInfo, with
|
|||
Permanode: withPermanode,
|
||||
}
|
||||
binKey, err := cacheKey.marshalBinary()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshaling cache key: %w", err)
|
||||
}
|
||||
binVal, err := c.db.Get(binKey, nil)
|
||||
if err != nil {
|
||||
if err == leveldb.ErrNotFound {
|
||||
|
|
|
@ -83,7 +83,7 @@ func (c *permanodeCmd) RunCommand(args []string) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("Error parsing time %q; expecting time of form %q", c.sigTime, format)
|
||||
}
|
||||
permaNode, err = up.UploadPlannedPermanode(ctxbg, c.key, sigTime)
|
||||
permaNode, err = up.UploadPlannedPermanode(ctxbg, c.key, sigTime) //lint:ignore SA4006 used by handleResult below
|
||||
}
|
||||
if handleResult("permanode", permaNode, err) != nil {
|
||||
return err
|
||||
|
@ -95,9 +95,8 @@ func (c *permanodeCmd) RunCommand(args []string) error {
|
|||
}
|
||||
if c.tag != "" {
|
||||
tags := strings.Split(c.tag, ",")
|
||||
m := schema.NewSetAttributeClaim(permaNode.BlobRef, "tag", tags[0])
|
||||
for _, tag := range tags {
|
||||
m = schema.NewAddAttributeClaim(permaNode.BlobRef, "tag", tag)
|
||||
m := schema.NewAddAttributeClaim(permaNode.BlobRef, "tag", tag)
|
||||
put, err := up.UploadAndSignBlob(ctxbg, m)
|
||||
handleResult("claim-permanode-tag", put, err)
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func (c *reindexdpCmd) RunCommand(args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
low := cfg.LowLevelJSONConfig()
|
||||
low := cfg.LowLevelJSONConfig() //lint:ignore SA1019 we use it
|
||||
prefixes, ok := low["prefixes"].(map[string]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("No 'prefixes' object in low-level (or converted) config file %s", osutil.UserServerConfigPath())
|
||||
|
|
|
@ -58,7 +58,7 @@ func (c *dumpconfigCmd) RunCommand(args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lowj, err := json.MarshalIndent(cfg.LowLevelJSONConfig(), "", " ")
|
||||
lowj, err := json.MarshalIndent(cfg.LowLevelJSONConfig(), "", " ") //lint:ignore SA1019 we use it still
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func whoamiType(c *client.Client, s *schema.Signer) error {
|
|||
if ent == nil {
|
||||
return errors.New("no identity")
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("%T", ent.PrivateKey.PrivateKey))
|
||||
fmt.Printf("%T\n", ent.PrivateKey.PrivateKey)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue