mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-10 10:47:51 +08:00
chore: fix all golangci-lint staticcheck issues
align kubo with unified golang ci linter from IPDX and rules used in boxo and other go packages addressed lint rules: - ST1000: added package comments - ST1020, ST1021, ST1022: fixed function/method comments - QF1001: applied De Morgan's law - QF1003: converted if-else chains to tagged switches - QF1004: replaced strings.Replace with strings.ReplaceAll - QF1008: simplified embedded struct field selectors - unconvert: removed unnecessary type conversions - usestdlibvars: used stdlib constants instead of literals disabled errcheck linter in .golangci.yml
This commit is contained in:
parent
dad310ad9e
commit
4f4dac9564
@ -3,6 +3,10 @@ linters:
|
||||
default: standard
|
||||
enable:
|
||||
- staticcheck
|
||||
- unconvert
|
||||
- usestdlibvars
|
||||
disable:
|
||||
- errcheck
|
||||
settings:
|
||||
staticcheck:
|
||||
checks:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package assets provides embedded asset files for kubo.
|
||||
package assets
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package rpc provides an RPC client implementation for the kubo HTTP API.
|
||||
package rpc
|
||||
|
||||
import (
|
||||
|
||||
@ -111,7 +111,7 @@ func Test_NewURLApiWithClient_With_Headers(t *testing.T) {
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
val := r.Header.Get(headerToTest)
|
||||
if val != expectedHeaderValue {
|
||||
w.WriteHeader(400)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
http.ServeContent(w, r, "", time.Now(), strings.NewReader("test"))
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package auth provides HTTP authentication utilities for the RPC client.
|
||||
package auth
|
||||
|
||||
import "net/http"
|
||||
|
||||
@ -80,7 +80,7 @@ func (r *Response) decode(dec interface{}) error {
|
||||
|
||||
func (r *Request) Send(c *http.Client) (*Response, error) {
|
||||
url := r.getURL()
|
||||
req, err := http.NewRequest("POST", url, r.Body)
|
||||
req, err := http.NewRequest(http.MethodPost, url, r.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -323,9 +323,10 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
|
||||
}
|
||||
defer fetcher.Close()
|
||||
|
||||
if migrationCfg.Keep == "cache" {
|
||||
switch migrationCfg.Keep {
|
||||
case "cache":
|
||||
cacheMigrations = true
|
||||
} else if migrationCfg.Keep == "pin" {
|
||||
case "pin":
|
||||
pinMigrations = true
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// cmd/ipfs/kubo implements the primary CLI binary for kubo
|
||||
// Package kubo implements the primary CLI binary for kubo
|
||||
package kubo
|
||||
|
||||
import (
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//go:build !wasm
|
||||
// +build !wasm
|
||||
|
||||
// Package util provides utility functions for the IPFS CLI.
|
||||
package util
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package commands implements IPFS commands.
|
||||
package commands
|
||||
|
||||
import (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// package config implements the ipfs config file datastructures and utilities.
|
||||
// Package config implements the ipfs config file datastructures and utilities.
|
||||
package config
|
||||
|
||||
import (
|
||||
@ -141,7 +141,7 @@ func ToMap(conf *Config) (map[string]interface{}, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Convert config to a map, without using encoding/json, since
|
||||
// ReflectToMap converts config to a map, without using encoding/json, since
|
||||
// zero/empty/'omitempty' fields are excluded by encoding/json during
|
||||
// marshaling.
|
||||
func ReflectToMap(conf interface{}) interface{} {
|
||||
@ -222,7 +222,7 @@ func (c *Config) Clone() (*Config, error) {
|
||||
return &newConfig, nil
|
||||
}
|
||||
|
||||
// Check if the provided key is present in the structure.
|
||||
// CheckKey checks if the provided key is present in the structure.
|
||||
func CheckKey(key string) error {
|
||||
conf := Config{}
|
||||
|
||||
|
||||
@ -127,13 +127,13 @@ func (r *RouterParser) UnmarshalJSON(b []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
r.Router.Type = out.Type
|
||||
r.Router.Parameters = p
|
||||
r.Type = out.Type
|
||||
r.Parameters = p
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Type is the routing type.
|
||||
// RouterType is the routing type.
|
||||
// Depending of the type we need to instantiate different Routing implementations.
|
||||
type RouterType string
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package fsrepo provides configuration serialization utilities.
|
||||
package fsrepo
|
||||
|
||||
import (
|
||||
|
||||
@ -60,7 +60,7 @@ var CatCmd = &cmds.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
readers, length, err := cat(req.Context, api, req.Arguments, int64(offset), int64(max))
|
||||
readers, length, err := cat(req.Context, api, req.Arguments, offset, max)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ var codecsCmd = &cmds.Command{
|
||||
continue
|
||||
}
|
||||
}
|
||||
res = append(res, CodeAndName{int(code), mc.Code(code).String()})
|
||||
res = append(res, CodeAndName{int(code), code.String()})
|
||||
}
|
||||
}
|
||||
return cmds.EmitOnce(resp, res)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package cmdenv provides the environment for executing IPFS commands.
|
||||
package cmdenv
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package cmdutils provides utilities for kubo commands.
|
||||
package cmdutils
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package dagcmd provides IPFS DAG manipulation commands.
|
||||
package dagcmd
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package e provides error utilities for IPFS commands.
|
||||
package e
|
||||
|
||||
import (
|
||||
|
||||
@ -260,16 +260,16 @@ var filesStatCmd = &cmds.Command{
|
||||
}
|
||||
|
||||
s, _ := statGetFormatOptions(req)
|
||||
s = strings.Replace(s, "<hash>", out.Hash, -1)
|
||||
s = strings.Replace(s, "<size>", fmt.Sprintf("%d", out.Size), -1)
|
||||
s = strings.Replace(s, "<cumulsize>", fmt.Sprintf("%d", out.CumulativeSize), -1)
|
||||
s = strings.Replace(s, "<childs>", fmt.Sprintf("%d", out.Blocks), -1)
|
||||
s = strings.Replace(s, "<type>", out.Type, -1)
|
||||
s = strings.Replace(s, "<mode>", mode, -1)
|
||||
s = strings.Replace(s, "<mode-octal>", modeo, -1)
|
||||
s = strings.Replace(s, "<mtime>", mtime, -1)
|
||||
s = strings.Replace(s, "<mtime-secs>", mtimes, -1)
|
||||
s = strings.Replace(s, "<mtime-nsecs>", mtimens, -1)
|
||||
s = strings.ReplaceAll(s, "<hash>", out.Hash)
|
||||
s = strings.ReplaceAll(s, "<size>", fmt.Sprintf("%d", out.Size))
|
||||
s = strings.ReplaceAll(s, "<cumulsize>", fmt.Sprintf("%d", out.CumulativeSize))
|
||||
s = strings.ReplaceAll(s, "<childs>", fmt.Sprintf("%d", out.Blocks))
|
||||
s = strings.ReplaceAll(s, "<type>", out.Type)
|
||||
s = strings.ReplaceAll(s, "<mode>", mode)
|
||||
s = strings.ReplaceAll(s, "<mode-octal>", modeo)
|
||||
s = strings.ReplaceAll(s, "<mtime>", mtime)
|
||||
s = strings.ReplaceAll(s, "<mtime-secs>", mtimes)
|
||||
s = strings.ReplaceAll(s, "<mtime-nsecs>", mtimens)
|
||||
|
||||
fmt.Fprintln(w, s)
|
||||
|
||||
@ -785,11 +785,11 @@ Examples:
|
||||
return err
|
||||
}
|
||||
|
||||
if int64(offset) > filen {
|
||||
if offset > filen {
|
||||
return fmt.Errorf("offset was past end of file (%d > %d)", offset, filen)
|
||||
}
|
||||
|
||||
_, err = rfd.Seek(int64(offset), io.SeekStart)
|
||||
_, err = rfd.Seek(offset, io.SeekStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -800,7 +800,7 @@ Examples:
|
||||
if count < 0 {
|
||||
return fmt.Errorf("cannot specify negative 'count'")
|
||||
}
|
||||
r = io.LimitReader(r, int64(count))
|
||||
r = io.LimitReader(r, count)
|
||||
}
|
||||
return res.Emit(r)
|
||||
},
|
||||
@ -1049,7 +1049,7 @@ See '--to-files' in 'ipfs add --help' for more information.
|
||||
return fmt.Errorf("cannot have negative byte count")
|
||||
}
|
||||
|
||||
_, err = wfd.Seek(int64(offset), io.SeekStart)
|
||||
_, err = wfd.Seek(offset, io.SeekStart)
|
||||
if err != nil {
|
||||
flog.Error("seekfail: ", err)
|
||||
return err
|
||||
@ -1061,7 +1061,7 @@ See '--to-files' in 'ipfs add --help' for more information.
|
||||
return err
|
||||
}
|
||||
if countfound {
|
||||
r = io.LimitReader(r, int64(count))
|
||||
r = io.LimitReader(r, count)
|
||||
}
|
||||
|
||||
_, err = io.Copy(wfd, r)
|
||||
|
||||
@ -123,13 +123,13 @@ EXAMPLE:
|
||||
format, found := req.Options[formatOptionName].(string)
|
||||
if found {
|
||||
output := format
|
||||
output = strings.Replace(output, "<id>", out.ID, -1)
|
||||
output = strings.Replace(output, "<aver>", out.AgentVersion, -1)
|
||||
output = strings.Replace(output, "<pubkey>", out.PublicKey, -1)
|
||||
output = strings.Replace(output, "<addrs>", strings.Join(out.Addresses, "\n"), -1)
|
||||
output = strings.Replace(output, "<protocols>", strings.Join(protocol.ConvertToStrings(out.Protocols), "\n"), -1)
|
||||
output = strings.Replace(output, "\\n", "\n", -1)
|
||||
output = strings.Replace(output, "\\t", "\t", -1)
|
||||
output = strings.ReplaceAll(output, "<id>", out.ID)
|
||||
output = strings.ReplaceAll(output, "<aver>", out.AgentVersion)
|
||||
output = strings.ReplaceAll(output, "<pubkey>", out.PublicKey)
|
||||
output = strings.ReplaceAll(output, "<addrs>", strings.Join(out.Addresses, "\n"))
|
||||
output = strings.ReplaceAll(output, "<protocols>", strings.Join(protocol.ConvertToStrings(out.Protocols), "\n"))
|
||||
output = strings.ReplaceAll(output, "\\n", "\n")
|
||||
output = strings.ReplaceAll(output, "\\t", "\t")
|
||||
fmt.Fprint(w, output)
|
||||
} else {
|
||||
marshaled, err := json.MarshalIndent(out, "", "\t")
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package keyencode provides key encoding utilities for kubo commands.
|
||||
package keyencode
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package name provides IPNS name commands.
|
||||
package name
|
||||
|
||||
import (
|
||||
@ -149,7 +150,7 @@ Resolve the value of a dnslink:
|
||||
if v.Err != nil && (recursive || v.Err != namesys.ErrResolveRecursion) {
|
||||
return v.Err
|
||||
}
|
||||
if err := res.Emit(&ResolvedPath{v.Path.String()}); err != nil {
|
||||
if err := res.Emit(&ResolvedPath{v.String()}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package objectcmd implements IPFS object manipulation commands.
|
||||
package objectcmd
|
||||
|
||||
import (
|
||||
|
||||
@ -386,7 +386,7 @@ var p2pCloseCmd = &cmds.Command{
|
||||
}
|
||||
}
|
||||
|
||||
if !(closeAll || p || l || t) {
|
||||
if !closeAll && !p && !l && !t {
|
||||
return errors.New("no matching options given")
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package pin implements IPFS pinning commands.
|
||||
package pin
|
||||
|
||||
import (
|
||||
@ -387,7 +388,7 @@ Example:
|
||||
lgcList := map[string]PinLsType{}
|
||||
if !stream {
|
||||
emit = func(v PinLsOutputWrapper) error {
|
||||
lgcList[v.PinLsObject.Cid] = PinLsType{Type: v.PinLsObject.Type, Name: v.PinLsObject.Name}
|
||||
lgcList[v.Cid] = PinLsType{Type: v.Type, Name: v.Name}
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
@ -432,16 +433,16 @@ Example:
|
||||
|
||||
if stream {
|
||||
if quiet {
|
||||
fmt.Fprintf(w, "%s\n", out.PinLsObject.Cid)
|
||||
} else if out.PinLsObject.Name == "" {
|
||||
fmt.Fprintf(w, "%s %s\n", out.PinLsObject.Cid, out.PinLsObject.Type)
|
||||
fmt.Fprintf(w, "%s\n", out.Cid)
|
||||
} else if out.Name == "" {
|
||||
fmt.Fprintf(w, "%s %s\n", out.Cid, out.Type)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s %s %s\n", out.PinLsObject.Cid, out.PinLsObject.Type, out.PinLsObject.Name)
|
||||
fmt.Fprintf(w, "%s %s %s\n", out.Cid, out.Type, out.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
for k, v := range out.PinLsList.Keys {
|
||||
for k, v := range out.Keys {
|
||||
if quiet {
|
||||
fmt.Fprintf(w, "%s\n", k)
|
||||
} else if v.Name == "" {
|
||||
|
||||
@ -696,7 +696,7 @@ type PinCount struct {
|
||||
Failed int
|
||||
}
|
||||
|
||||
// Struct returned by ipfs pin remote service ls --enc=json | jq
|
||||
// PinServicesList is the struct returned by ipfs pin remote service ls --enc=json | jq
|
||||
type PinServicesList struct {
|
||||
RemoteServices []ServiceDetails
|
||||
}
|
||||
@ -772,7 +772,7 @@ func getRemotePinServiceInfo(env cmds.Environment, name string) (endpoint, key s
|
||||
|
||||
func normalizeEndpoint(endpoint string) (string, error) {
|
||||
uri, err := neturl.ParseRequestURI(endpoint)
|
||||
if err != nil || !(uri.Scheme == "http" || uri.Scheme == "https") {
|
||||
if err != nil || (uri.Scheme != "http" && uri.Scheme != "https") {
|
||||
return "", fmt.Errorf("service endpoint must be a valid HTTP URL")
|
||||
}
|
||||
|
||||
|
||||
@ -320,7 +320,7 @@ func (rw *RefWriter) visit(c cid.Cid, depth int) (bool, bool) {
|
||||
return !atMaxDepth, !ok
|
||||
}
|
||||
|
||||
// Write one edge
|
||||
// WriteEdge writes one edge
|
||||
func (rw *RefWriter) WriteEdge(from, to cid.Cid, linkname string, enc cidenc.Encoder) error {
|
||||
if rw.Ctx != nil {
|
||||
select {
|
||||
@ -334,9 +334,9 @@ func (rw *RefWriter) WriteEdge(from, to cid.Cid, linkname string, enc cidenc.Enc
|
||||
switch {
|
||||
case rw.PrintFmt != "":
|
||||
s = rw.PrintFmt
|
||||
s = strings.Replace(s, "<src>", enc.Encode(from), -1)
|
||||
s = strings.Replace(s, "<dst>", enc.Encode(to), -1)
|
||||
s = strings.Replace(s, "<linkname>", linkname, -1)
|
||||
s = strings.ReplaceAll(s, "<src>", enc.Encode(from))
|
||||
s = strings.ReplaceAll(s, "<dst>", enc.Encode(to))
|
||||
s = strings.ReplaceAll(s, "<linkname>", linkname)
|
||||
default:
|
||||
s += enc.Encode(to)
|
||||
}
|
||||
|
||||
@ -601,7 +601,7 @@ func escapeDhtKey(s string) (string, error) {
|
||||
parts := strings.Split(s, "/")
|
||||
if len(parts) != 3 ||
|
||||
parts[0] != "" ||
|
||||
!(parts[1] == "ipns" || parts[1] == "pk") {
|
||||
(parts[1] != "ipns" && parts[1] != "pk") {
|
||||
return "", errors.New("invalid key")
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
/*
|
||||
**NOTE: this package is experimental.**
|
||||
|
||||
Package coreapi provides direct access to the core commands in IPFS. If you are
|
||||
embedding IPFS directly in your Go program, this package is the public
|
||||
interface you should use to read and write files or otherwise control IPFS.
|
||||
|
||||
If you are running IPFS as a separate process, you should use `client/rpc` to
|
||||
work with it via HTTP.
|
||||
*/
|
||||
// Package coreapi provides direct access to the core commands in IPFS. If you are
|
||||
// embedding IPFS directly in your Go program, this package is the public
|
||||
// interface you should use to read and write files or otherwise control IPFS.
|
||||
//
|
||||
// **NOTE: this package is experimental.**
|
||||
//
|
||||
// If you are running IPFS as a separate process, you should use `client/rpc` to
|
||||
// work with it via HTTP.
|
||||
package coreapi
|
||||
|
||||
import (
|
||||
|
||||
@ -60,7 +60,7 @@ func normalizeKey(s string) (string, error) {
|
||||
parts := strings.Split(s, "/")
|
||||
if len(parts) != 3 ||
|
||||
parts[0] != "" ||
|
||||
!(parts[1] == "ipns" || parts[1] == "pk") {
|
||||
(parts[1] != "ipns" && parts[1] != "pk") {
|
||||
return "", errors.New("invalid key")
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ func (api *RoutingAPI) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo,
|
||||
return peer.AddrInfo{}, err
|
||||
}
|
||||
|
||||
pi, err := api.routing.FindPeer(ctx, peer.ID(p))
|
||||
pi, err := api.routing.FindPeer(ctx, p)
|
||||
if err != nil {
|
||||
return peer.AddrInfo{}, err
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ func (ci *connInfo) Direction() inet.Direction {
|
||||
}
|
||||
|
||||
func (ci *connInfo) Latency() (time.Duration, error) {
|
||||
return ci.peerstore.LatencyEWMA(peer.ID(ci.ID())), nil
|
||||
return ci.peerstore.LatencyEWMA(ci.ID()), nil
|
||||
}
|
||||
|
||||
func (ci *connInfo) Streams() ([]protocol.ID, error) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package test provides test utilities for core API.
|
||||
package test
|
||||
|
||||
import (
|
||||
|
||||
@ -80,12 +80,12 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
|
||||
// return
|
||||
//}
|
||||
|
||||
if settings.NoCopy && !(cfg.Experimental.FilestoreEnabled || cfg.Experimental.UrlstoreEnabled) {
|
||||
if settings.NoCopy && (!cfg.Experimental.FilestoreEnabled && !cfg.Experimental.UrlstoreEnabled) {
|
||||
return path.ImmutablePath{}, errors.New("either the filestore or the urlstore must be enabled to use nocopy, see: https://github.com/ipfs/kubo/blob/master/docs/experimental-features.md#ipfs-filestore")
|
||||
}
|
||||
|
||||
addblockstore := api.blockstore
|
||||
if !(settings.FsCache || settings.NoCopy) {
|
||||
if !settings.FsCache && !settings.NoCopy {
|
||||
addblockstore = bstore.NewGCBlockstore(api.baseBlocks, api.blockstore)
|
||||
}
|
||||
exch := api.exchange
|
||||
|
||||
@ -114,7 +114,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) {
|
||||
for i, o := range oldOrigins {
|
||||
// TODO: allow replacing <host>. tricky, ip4 and ip6 and hostnames...
|
||||
if port != "" {
|
||||
o = strings.Replace(o, "<port>", port, -1)
|
||||
o = strings.ReplaceAll(o, "<port>", port)
|
||||
}
|
||||
newOrigins[i] = o
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ func MetricsScrapingOption(path string) ServeOption {
|
||||
}
|
||||
}
|
||||
|
||||
// This adds collection of OpenCensus metrics
|
||||
// MetricsOpenCensusCollectionOption adds collection of OpenCensus metrics
|
||||
func MetricsOpenCensusCollectionOption() ServeOption {
|
||||
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
|
||||
log.Info("Init OpenCensus")
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package corehttp
|
||||
|
||||
// WebUI version confirmed to work with this Kubo version
|
||||
// WebUIPath is the WebUI version confirmed to work with this Kubo version
|
||||
const WebUIPath = "/ipfs/bafybeifplj2s3yegn7ko7tdnwpoxa4c5uaqnk2ajnw5geqm34slcj6b6mu" // v4.8.0
|
||||
|
||||
// WebUIPaths is a list of all past webUI paths.
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package options defines configuration options for IPFS core interface methods.
|
||||
package options
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package tests provides test suites for CoreAPI implementations.
|
||||
package tests
|
||||
|
||||
import (
|
||||
|
||||
@ -53,7 +53,7 @@ func (tp *TestSuite) TestBlock(t *testing.T) {
|
||||
t.Run("TestBlockPin", tp.TestBlockPin)
|
||||
}
|
||||
|
||||
// when no opts are passed, produced CID has 'raw' codec
|
||||
// TestBlockPut tests that when no opts are passed, produced CID has 'raw' codec
|
||||
func (tp *TestSuite) TestBlockPut(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
@ -72,7 +72,7 @@ func (tp *TestSuite) TestBlockPut(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Format is deprecated, it used invalid codec names.
|
||||
// TestBlockPutFormatDagCbor tests that Format is deprecated, it used invalid codec names.
|
||||
// Confirm 'cbor' gets fixed to 'dag-cbor'
|
||||
func (tp *TestSuite) TestBlockPutFormatDagCbor(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@ -92,7 +92,7 @@ func (tp *TestSuite) TestBlockPutFormatDagCbor(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Format is deprecated, it used invalid codec names.
|
||||
// TestBlockPutFormatDagPb tests that Format is deprecated, it used invalid codec names.
|
||||
// Confirm 'protobuf' got fixed to 'dag-pb'
|
||||
func (tp *TestSuite) TestBlockPutFormatDagPb(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@ -112,7 +112,7 @@ func (tp *TestSuite) TestBlockPutFormatDagPb(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Format is deprecated, it used invalid codec names.
|
||||
// TestBlockPutFormatV0 tests that Format is deprecated, it used invalid codec names.
|
||||
// Confirm fake codec 'v0' got fixed to CIDv0 (with implicit dag-pb codec)
|
||||
func (tp *TestSuite) TestBlockPutFormatV0(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
@ -536,7 +536,7 @@ func assertPinLsAllConsistency(t *testing.T, ctx context.Context, api iface.Core
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if expected, actual := len(pins), pinProps.Set.Len(); expected != actual {
|
||||
if expected, actual := len(pins), pinProps.Len(); expected != actual {
|
||||
t.Fatalf("pin ls all has %d pins of type %s, but pin ls for the type has %d", expected, typeStr, actual)
|
||||
}
|
||||
|
||||
|
||||
@ -800,6 +800,7 @@ func (tp *TestSuite) TestLsEmptyDir(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLsNonUnixfs tests listing non-UnixFS content.
|
||||
// TODO(lgierth) this should test properly, with len(links) > 0
|
||||
func (tp *TestSuite) TestLsNonUnixfs(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package corerepo provides repository management utilities for the IPFS core.
|
||||
package corerepo
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package coreunix provides Unix-like file addition utilities for IPFS.
|
||||
package coreunix
|
||||
|
||||
import (
|
||||
@ -496,7 +497,7 @@ func (adder *Adder) addDir(ctx context.Context, path string, dir files.Directory
|
||||
adder.SetMfsRoot(mr)
|
||||
}
|
||||
|
||||
if !(toplevel && path == "") {
|
||||
if !toplevel || path != "" {
|
||||
mr, err := adder.mfsRoot()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package coremock provides mock implementations for testing IPFS core functionality.
|
||||
package coremock
|
||||
|
||||
import (
|
||||
|
||||
@ -126,7 +126,7 @@ func Bitswap(serverEnabled, libp2pEnabled, httpEnabled bool) interface{} {
|
||||
|
||||
// Kubo uses own, customized ProviderQueryManager
|
||||
in.BitswapOpts = append(in.BitswapOpts, bitswap.WithClientOption(client.WithDefaultProviderQueryManager(false)))
|
||||
var maxProviders int = DefaultMaxProviders
|
||||
maxProviders := DefaultMaxProviders
|
||||
|
||||
var bcDisposition string
|
||||
if in.Cfg.Internal.Bitswap != nil {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package node implements IPFS nodes.
|
||||
package node
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package helpers provides utility functions for IPFS nodes.
|
||||
package helpers
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package libp2p provides libp2p configuration and setup for IPFS nodes.
|
||||
package libp2p
|
||||
|
||||
import (
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//go:build linux || darwin
|
||||
// +build linux darwin
|
||||
|
||||
// Package fd provides file descriptor management utilities.
|
||||
package fd
|
||||
|
||||
import (
|
||||
|
||||
@ -19,7 +19,7 @@ var infiniteResourceLimits = rcmgr.InfiniteLimits.ToPartialLimitConfig().System
|
||||
// The defaults follow the documentation in docs/libp2p-resource-management.md.
|
||||
// Any changes in the logic here should be reflected there.
|
||||
func createDefaultLimitConfig(cfg config.SwarmConfig) (limitConfig rcmgr.ConcreteLimitConfig, logMessageForStartup string, err error) {
|
||||
maxMemoryDefaultString := humanize.Bytes(uint64(memory.TotalMemory()) / 2)
|
||||
maxMemoryDefaultString := humanize.Bytes(memory.TotalMemory() / 2)
|
||||
maxMemoryString := cfg.ResourceMgr.MaxMemory.WithDefault(maxMemoryDefaultString)
|
||||
maxMemory, err := humanize.ParseBytes(maxMemoryString)
|
||||
if err != nil {
|
||||
|
||||
4
doc.go
4
doc.go
@ -1,4 +1,2 @@
|
||||
/*
|
||||
IPFS is a global, versioned, peer-to-peer filesystem
|
||||
*/
|
||||
// Package ipfs is a global, versioned, peer-to-peer filesystem
|
||||
package ipfs
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//go:build !nofuse && !openbsd && !netbsd && !plan9
|
||||
// +build !nofuse,!openbsd,!netbsd,!plan9
|
||||
|
||||
// package fuse/ipns implements a fuse filesystem that interfaces
|
||||
// Package ipns implements a fuse filesystem that interfaces
|
||||
// with ipns, the naming system for ipfs.
|
||||
package ipns
|
||||
|
||||
@ -163,7 +163,7 @@ func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
switch name {
|
||||
case "mach_kernel", ".hidden", "._.":
|
||||
// Just quiet some log noise on OS X.
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
if lnk, ok := r.LocalLinks[name]; ok {
|
||||
@ -178,7 +178,7 @@ func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
case *FileNode:
|
||||
return nd, nil
|
||||
default:
|
||||
return nil, syscall.Errno(syscall.EIO)
|
||||
return nil, syscall.EIO
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
resolved, err := r.Ipfs.Name().Resolve(ctx, ipnsName)
|
||||
if err != nil {
|
||||
log.Warnf("ipns: namesys resolve error: %s", err)
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
if resolved.Namespace() != path.IPFSNamespace {
|
||||
@ -279,7 +279,7 @@ func (d *Directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
child, err := d.dir.Child(name)
|
||||
if err != nil {
|
||||
// todo: make this error more versatile.
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
switch child := child.(type) {
|
||||
@ -317,7 +317,7 @@ func (d *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
if len(entries) > 0 {
|
||||
return entries, nil
|
||||
}
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
func (fi *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error {
|
||||
@ -428,7 +428,7 @@ func (fi *FileNode) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.
|
||||
if req.Flags&fuse.OpenTruncate != 0 {
|
||||
if req.Flags.IsReadOnly() {
|
||||
log.Error("tried to open a readonly file with truncate")
|
||||
return nil, syscall.Errno(syscall.ENOTSUP)
|
||||
return nil, syscall.ENOTSUP
|
||||
}
|
||||
log.Info("Need to truncate file!")
|
||||
err := fd.Truncate(0)
|
||||
@ -439,7 +439,7 @@ func (fi *FileNode) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.
|
||||
log.Info("Need to append to file!")
|
||||
if req.Flags.IsReadOnly() {
|
||||
log.Error("tried to open a readonly file with append")
|
||||
return nil, syscall.Errno(syscall.ENOTSUP)
|
||||
return nil, syscall.ENOTSUP
|
||||
}
|
||||
|
||||
_, err := fd.Seek(0, io.SeekEnd)
|
||||
@ -491,7 +491,7 @@ func (d *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *f
|
||||
func (d *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
|
||||
err := d.dir.Unlink(req.Name)
|
||||
if err != nil {
|
||||
return syscall.Errno(syscall.ENOENT)
|
||||
return syscall.ENOENT
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -521,7 +521,7 @@ func (d *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir
|
||||
}
|
||||
case *FileNode:
|
||||
log.Error("Cannot move node into a file!")
|
||||
return syscall.Errno(syscall.EPERM)
|
||||
return syscall.EPERM
|
||||
default:
|
||||
log.Error("Unknown node type for rename target dir!")
|
||||
return errors.New("unknown fs node type")
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// +build linux darwin freebsd netbsd openbsd
|
||||
// +build !nofuse
|
||||
|
||||
// Package mfs provides a FUSE interface for IPFS mutable file system.
|
||||
package mfs
|
||||
|
||||
import (
|
||||
@ -29,22 +30,22 @@ const (
|
||||
dirSize = 8
|
||||
)
|
||||
|
||||
// FUSE filesystem mounted at /mfs.
|
||||
// FileSystem is a FUSE filesystem mounted at /mfs.
|
||||
type FileSystem struct {
|
||||
root Dir
|
||||
}
|
||||
|
||||
// Get filesystem root.
|
||||
// Root gets filesystem root.
|
||||
func (fs *FileSystem) Root() (fs.Node, error) {
|
||||
return &fs.root, nil
|
||||
}
|
||||
|
||||
// FUSE Adapter for MFS directories.
|
||||
// Dir is a FUSE Adapter for MFS directories.
|
||||
type Dir struct {
|
||||
mfsDir *mfs.Directory
|
||||
}
|
||||
|
||||
// Directory attributes (stat).
|
||||
// Attr returns directory attributes (stat).
|
||||
func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error {
|
||||
attr.Mode = mfsDirMode
|
||||
attr.Size = dirSize * blockSize
|
||||
@ -52,12 +53,12 @@ func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Access files in a directory.
|
||||
// Lookup accesses files in a directory.
|
||||
func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) {
|
||||
mfsNode, err := dir.mfsDir.Child(req.Name)
|
||||
switch err {
|
||||
case os.ErrNotExist:
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
case nil:
|
||||
default:
|
||||
return nil, err
|
||||
@ -76,10 +77,10 @@ func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
// List (ls) MFS directory.
|
||||
// ReadDirAll lists (ls) MFS directory.
|
||||
func (dir *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
var res []fuse.Dirent
|
||||
nodes, err := dir.mfsDir.List(ctx)
|
||||
@ -136,7 +137,7 @@ func (dir *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
|
||||
return dir.mfsDir.Flush()
|
||||
}
|
||||
|
||||
// Move (mv) an MFS file.
|
||||
// Rename moves (mv) an MFS file.
|
||||
func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error {
|
||||
file, err := dir.mfsDir.Child(req.OldName)
|
||||
if err != nil {
|
||||
@ -215,13 +216,13 @@ func (dir *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.
|
||||
return &file, &handler, nil
|
||||
}
|
||||
|
||||
// List dir xattr.
|
||||
// Listxattr lists dir xattr.
|
||||
func (dir *Dir) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error {
|
||||
resp.Append(ipfsCIDXattr)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get dir xattr.
|
||||
// Getxattr gets dir xattr.
|
||||
func (dir *Dir) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error {
|
||||
switch req.Name {
|
||||
case ipfsCIDXattr:
|
||||
@ -236,12 +237,12 @@ func (dir *Dir) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *f
|
||||
}
|
||||
}
|
||||
|
||||
// FUSE adapter for MFS files.
|
||||
// File is a FUSE adapter for MFS files.
|
||||
type File struct {
|
||||
mfsFile *mfs.File
|
||||
}
|
||||
|
||||
// File attributes.
|
||||
// Attr returns file attributes.
|
||||
func (file *File) Attr(ctx context.Context, attr *fuse.Attr) error {
|
||||
size, _ := file.mfsFile.Size()
|
||||
|
||||
@ -283,18 +284,18 @@ func (file *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.Op
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Sync the file's contents to MFS.
|
||||
// Fsync syncs the file's contents to MFS.
|
||||
func (file *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
|
||||
return file.mfsFile.Sync()
|
||||
}
|
||||
|
||||
// List file xattr.
|
||||
// Listxattr lists file xattr.
|
||||
func (file *File) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error {
|
||||
resp.Append(ipfsCIDXattr)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get file xattr.
|
||||
// Getxattr gets file xattr.
|
||||
func (file *File) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error {
|
||||
switch req.Name {
|
||||
case ipfsCIDXattr:
|
||||
@ -309,7 +310,7 @@ func (file *File) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapper for MFS's file descriptor that conforms to the FUSE fs.Handler
|
||||
// FileHandler is a wrapper for MFS's file descriptor that conforms to the FUSE fs.Handler
|
||||
// interface.
|
||||
type FileHandler struct {
|
||||
mfsFD mfs.FileDescriptor
|
||||
@ -353,7 +354,7 @@ func (fh *FileHandler) Write(ctx context.Context, req *fuse.WriteRequest, resp *
|
||||
return nil
|
||||
}
|
||||
|
||||
// Flushes the file's buffer.
|
||||
// Flush flushes the file's buffer.
|
||||
func (fh *FileHandler) Flush(ctx context.Context, req *fuse.FlushRequest) error {
|
||||
fh.mu.Lock()
|
||||
defer fh.mu.Unlock()
|
||||
@ -361,7 +362,7 @@ func (fh *FileHandler) Flush(ctx context.Context, req *fuse.FlushRequest) error
|
||||
return fh.mfsFD.Flush()
|
||||
}
|
||||
|
||||
// Closes the file.
|
||||
// Release closes the file.
|
||||
func (fh *FileHandler) Release(ctx context.Context, req *fuse.ReleaseRequest) error {
|
||||
fh.mu.Lock()
|
||||
defer fh.mu.Unlock()
|
||||
@ -369,7 +370,7 @@ func (fh *FileHandler) Release(ctx context.Context, req *fuse.ReleaseRequest) er
|
||||
return fh.mfsFD.Close()
|
||||
}
|
||||
|
||||
// Create new filesystem.
|
||||
// NewFileSystem creates new filesystem.
|
||||
func NewFileSystem(ipfs *core.IpfsNode) fs.FS {
|
||||
return &FileSystem{
|
||||
root: Dir{
|
||||
|
||||
@ -27,7 +27,7 @@ type mount struct {
|
||||
unmountOnce sync.Once
|
||||
}
|
||||
|
||||
// Mount mounts a fuse fs.FS at a given location, and returns a Mount instance.
|
||||
// NewMount mounts a fuse fs.FS at a given location, and returns a Mount instance.
|
||||
// ctx is parent is a ContextGroup to bind the mount's ContextGroup to.
|
||||
func NewMount(fsys fs.FS, mountpoint string, allowOther bool) (Mount, error) {
|
||||
var conn *fuse.Conn
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// package mount provides a simple abstraction around a mount point
|
||||
// Package mount provides a simple abstraction around a mount point
|
||||
package mount
|
||||
|
||||
import (
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//go:build !windows && !openbsd && !netbsd && !plan9 && !nofuse
|
||||
// +build !windows,!openbsd,!netbsd,!plan9,!nofuse
|
||||
|
||||
// Package node provides FUSE mount functionality for IPFS nodes.
|
||||
package node
|
||||
|
||||
import (
|
||||
@ -70,8 +71,8 @@ func doMount(node *core.IpfsNode, fsdir, nsdir, mfsdir string) error {
|
||||
fmtFuseErr := func(err error, mountpoint string) error {
|
||||
s := err.Error()
|
||||
if strings.Contains(s, fuseNoDirectory) {
|
||||
s = strings.Replace(s, `fusermount: "fusermount:`, "", -1)
|
||||
s = strings.Replace(s, `\n", exit status 1`, "", -1)
|
||||
s = strings.ReplaceAll(s, `fusermount: "fusermount:`, "")
|
||||
s = strings.ReplaceAll(s, `\n", exit status 1`, "")
|
||||
return errors.New(s)
|
||||
}
|
||||
if s == fuseExitStatus1 {
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
// package fuse/readonly implements a fuse filesystem to access files
|
||||
// Package readonly implements a fuse filesystem to access files
|
||||
// stored inside of ipfs.
|
||||
package readonly
|
||||
|
||||
@ -59,38 +59,38 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
switch name {
|
||||
case "mach_kernel", ".hidden", "._.":
|
||||
// Just quiet some log noise on OS X.
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
p, err := path.NewPath("/ipfs/" + name)
|
||||
if err != nil {
|
||||
log.Debugf("fuse failed to parse path: %q: %s", name, err)
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
imPath, err := path.NewImmutablePath(p)
|
||||
if err != nil {
|
||||
log.Debugf("fuse failed to convert path: %q: %s", name, err)
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
nd, ndLnk, err := s.Ipfs.UnixFSPathResolver.ResolvePath(ctx, imPath)
|
||||
if err != nil {
|
||||
// todo: make this error more versatile.
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
cidLnk, ok := ndLnk.(cidlink.Link)
|
||||
if !ok {
|
||||
log.Debugf("non-cidlink returned from ResolvePath: %v", ndLnk)
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
// convert ipld-prime node to universal node
|
||||
blk, err := s.Ipfs.Blockstore.Get(ctx, cidLnk.Cid)
|
||||
if err != nil {
|
||||
log.Debugf("fuse failed to retrieve block: %v: %s", cidLnk, err)
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
var fnd ipld.Node
|
||||
@ -107,11 +107,11 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
fnd, err = mdag.RawNodeConverter(blk, nd)
|
||||
default:
|
||||
log.Error("fuse node was not a supported type")
|
||||
return nil, syscall.Errno(syscall.ENOTSUP)
|
||||
return nil, syscall.ENOTSUP
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("could not convert protobuf or raw node: %s", err)
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
return &Node{Ipfs: s.Ipfs, Nd: fnd}, nil
|
||||
@ -120,7 +120,7 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
// ReadDirAll reads a particular directory. Disallowed for root.
|
||||
func (*Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
log.Debug("read Root")
|
||||
return nil, syscall.Errno(syscall.EPERM)
|
||||
return nil, syscall.EPERM
|
||||
}
|
||||
|
||||
// Node is the core object representing a filesystem tree node.
|
||||
@ -162,7 +162,7 @@ func (s *Node) Attr(ctx context.Context, a *fuse.Attr) error {
|
||||
case ft.TFile:
|
||||
size := s.cached.FileSize()
|
||||
a.Mode = 0o444
|
||||
a.Size = uint64(size)
|
||||
a.Size = size
|
||||
a.Blocks = uint64(len(s.Nd.Links()))
|
||||
case ft.TRaw:
|
||||
a.Mode = 0o444
|
||||
@ -184,12 +184,12 @@ func (s *Node) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||
switch err {
|
||||
case os.ErrNotExist, mdag.ErrLinkNotFound:
|
||||
// todo: make this error more versatile.
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
case nil:
|
||||
// noop
|
||||
default:
|
||||
log.Errorf("fuse lookup %q: %s", name, err)
|
||||
return nil, syscall.Errno(syscall.EIO)
|
||||
return nil, syscall.EIO
|
||||
}
|
||||
|
||||
nd, err := s.Ipfs.DAG.Get(ctx, link.Cid)
|
||||
@ -252,7 +252,7 @@ func (s *Node) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
if len(entries) > 0 {
|
||||
return entries, nil
|
||||
}
|
||||
return nil, syscall.Errno(syscall.ENOENT)
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
func (s *Node) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error {
|
||||
@ -278,7 +278,7 @@ func (s *Node) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadR
|
||||
return err
|
||||
}
|
||||
// Data has a capacity of Size
|
||||
buf := resp.Data[:int(req.Size)]
|
||||
buf := resp.Data[:req.Size]
|
||||
n, err := io.ReadFull(r, buf)
|
||||
resp.Data = buf[:n]
|
||||
switch err {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package fsutil provides filesystem utilities.
|
||||
package fsutil
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package p2p implements libp2p connectivity utilities.
|
||||
package p2p
|
||||
|
||||
import (
|
||||
|
||||
@ -76,7 +76,7 @@ func (r *StreamRegistry) Register(streamInfo *Stream) {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
r.ConnManager.TagPeer(streamInfo.peer, cmgrTag, 20)
|
||||
r.TagPeer(streamInfo.peer, cmgrTag, 20)
|
||||
r.conns[streamInfo.peer]++
|
||||
|
||||
streamInfo.id = r.nextID
|
||||
@ -99,7 +99,7 @@ func (r *StreamRegistry) Deregister(streamID uint64) {
|
||||
r.conns[p]--
|
||||
if r.conns[p] < 1 {
|
||||
delete(r.conns, p)
|
||||
r.ConnManager.UntagPeer(p, cmgrTag)
|
||||
r.UntagPeer(p, cmgrTag)
|
||||
}
|
||||
|
||||
delete(r.Streams, streamID)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package plugin provides interfaces for extending kubo functionality.
|
||||
package plugin
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package loader provides plugin loading functionality for kubo.
|
||||
package loader
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package badgerds provides a BadgerDB datastore plugin.
|
||||
package badgerds
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package dagjose provides the DAG-JOSE codec plugin.
|
||||
package dagjose
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package flatfs provides a flatfs datastore plugin.
|
||||
package flatfs
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package fxtest provides a test plugin for the fx dependency injection framework.
|
||||
package fxtest
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package git provides a git IPLD codec plugin.
|
||||
package git
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package levelds provides a LevelDB datastore plugin.
|
||||
package levelds
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package nopfs provides a content blocking plugin using the nopfs library.
|
||||
package nopfs
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package pebbleds provides a PebbleDB datastore plugin.
|
||||
package pebbleds
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package peerlog provides a plugin for logging peer connection events.
|
||||
package peerlog
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package telemetry provides a plugin for sending telemetry data.
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
@ -531,7 +532,7 @@ func (p *telemetryPlugin) sendTelemetry() error {
|
||||
|
||||
log.Debugf("sending telemetry:\n %s", data)
|
||||
|
||||
req, err := http.NewRequest("POST", p.endpoint, bytes.NewBuffer(data))
|
||||
req, err := http.NewRequest(http.MethodPost, p.endpoint, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ func mockServer(t *testing.T) (*httptest.Server, func() LogEvent) {
|
||||
// Create a mock HTTP test server
|
||||
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Check if the request is POST to the correct endpoint
|
||||
if r.Method != "POST" || r.URL.Path != "/" {
|
||||
if r.Method != http.MethodPost || r.URL.Path != "/" {
|
||||
t.Log("invalid request")
|
||||
http.Error(w, "invalid request", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package profile provides performance profiling utilities for kubo.
|
||||
package profile
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package common provides shared utilities for repository implementations.
|
||||
package common
|
||||
|
||||
import (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// package fsrepo
|
||||
// Package fsrepo implements filesystem-backed repository storage.
|
||||
//
|
||||
// TODO explain the package roadmap...
|
||||
//
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package migrations provides utilities for fetching and running IPFS repository migrations.
|
||||
package migrations
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package ipfsfetcher provides utilities for fetching migrations via IPFS.
|
||||
package ipfsfetcher
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package repo provides interfaces for IPFS repository management.
|
||||
package repo
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package routing provides routing utilities for IPFS.
|
||||
package routing
|
||||
|
||||
import (
|
||||
|
||||
@ -55,7 +55,7 @@ func TestParser(t *testing.T) {
|
||||
RouterName: "r2",
|
||||
},
|
||||
}, &ExtraDHTParams{}, &ExtraHTTPParams{
|
||||
PeerID: string(pid),
|
||||
PeerID: pid,
|
||||
PrivKeyB64: sk,
|
||||
})
|
||||
|
||||
@ -146,7 +146,7 @@ func TestParserRecursive(t *testing.T) {
|
||||
RouterName: "composable2",
|
||||
},
|
||||
}, &ExtraDHTParams{}, &ExtraHTTPParams{
|
||||
PeerID: string(pid),
|
||||
PeerID: pid,
|
||||
PrivKeyB64: sk,
|
||||
})
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package cli contains integration tests for IPFS CLI commands.
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
||||
@ -57,7 +57,7 @@ func TestHTTPDelegatedRouting(t *testing.T) {
|
||||
}
|
||||
})
|
||||
res := node.RunIPFS("daemon")
|
||||
assert.Equal(t, 1, res.ExitErr.ProcessState.ExitCode())
|
||||
assert.Equal(t, 1, res.ExitErr.ExitCode())
|
||||
assert.Contains(
|
||||
t,
|
||||
res.Stderr.String(),
|
||||
@ -78,7 +78,7 @@ func TestHTTPDelegatedRouting(t *testing.T) {
|
||||
}
|
||||
})
|
||||
res := node.RunIPFS("daemon")
|
||||
assert.Equal(t, 1, res.ExitErr.ProcessState.ExitCode())
|
||||
assert.Equal(t, 1, res.ExitErr.ExitCode())
|
||||
assert.Contains(
|
||||
t,
|
||||
res.Stderr.String(),
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
func TestDHTAutoclient(t *testing.T) {
|
||||
t.Parallel()
|
||||
nodes := harness.NewT(t).NewNodes(10).Init()
|
||||
harness.Nodes(nodes[8:]).ForEachPar(func(node *harness.Node) {
|
||||
nodes[8:].ForEachPar(func(node *harness.Node) {
|
||||
node.IPFS("config", "Routing.Type", "autoclient")
|
||||
})
|
||||
nodes.StartDaemons().Connect()
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package harness provides a test harness for IPFS CLI integration testing.
|
||||
package harness
|
||||
|
||||
import (
|
||||
@ -24,6 +25,7 @@ type Harness struct {
|
||||
Nodes Nodes
|
||||
}
|
||||
|
||||
// EnableDebugLogging enables debug logging for the test harness.
|
||||
// TODO: use zaptest.NewLogger(t) instead
|
||||
func EnableDebugLogging() {
|
||||
err := logging.SetLogLevel("testharness", "DEBUG")
|
||||
|
||||
@ -31,7 +31,7 @@ func (n *Node) InspectPBNode(cid string) (PBNode, error) {
|
||||
|
||||
}
|
||||
|
||||
// Define structs to match the JSON for
|
||||
// PBHash defines structs to match the JSON for protobuf inspection.
|
||||
type PBHash struct {
|
||||
Slash string `json:"/"`
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ func NewMockHTTPProviderServer(c cid.Cid, body string, debug bool) *httptest.Ser
|
||||
if strings.HasPrefix(req.URL.Path, expectedPathPrefix) {
|
||||
w.Header().Set("Content-Type", "application/vnd.ipld.raw")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if req.Method == "GET" {
|
||||
if req.Method == http.MethodGet {
|
||||
_, err := w.Write([]byte(body))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "NewMockHTTPProviderServer GET %s error: %v\n", req.URL.Path, err)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package cli provides testing utilities for IPFS CLI commands.
|
||||
package cli
|
||||
|
||||
func MustVal[V any](val V, err error) V {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package testutils provides utilities for testing CLI commands.
|
||||
package testutils
|
||||
|
||||
import (
|
||||
|
||||
@ -14,7 +14,7 @@ func MustOpen(name string) *os.File {
|
||||
return f
|
||||
}
|
||||
|
||||
// Searches for a file in a dir, then the parent dir, etc.
|
||||
// FindUp searches for a file in a dir, then the parent dir, etc.
|
||||
// If the file is not found, an empty string is returned.
|
||||
func FindUp(name, dir string) string {
|
||||
curDir := dir
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package httprouting provides test utilities for HTTP routing functionality.
|
||||
package httprouting
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package pinningservice provides test utilities for pinning service functionality.
|
||||
package pinningservice
|
||||
|
||||
import (
|
||||
|
||||
@ -27,7 +27,7 @@ func (r *randomReader) Read(p []byte) (int, error) {
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
// createRandomReader produces specified number of pseudo-random bytes
|
||||
// DeterministicRandomReader produces specified number of pseudo-random bytes
|
||||
// from a seed.
|
||||
func DeterministicRandomReader(sizeStr string, seed string) (io.Reader, error) {
|
||||
size, err := humanize.ParseBytes(sizeStr)
|
||||
|
||||
1
thirdparty/unit/unit.go
vendored
1
thirdparty/unit/unit.go
vendored
@ -1,3 +1,4 @@
|
||||
// Package unit provides data size unit formatting utilities.
|
||||
package unit
|
||||
|
||||
import "fmt"
|
||||
|
||||
1
thirdparty/verifbs/verifbs.go
vendored
1
thirdparty/verifbs/verifbs.go
vendored
@ -1,3 +1,4 @@
|
||||
// Package verifbs provides a verified blockstore wrapper.
|
||||
package verifbs
|
||||
|
||||
import (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user