fix lint errors.

This commit is contained in:
Raúl Kripalani 2020-08-16 11:40:35 +01:00
parent 1eed341951
commit 2b511d2f57
25 changed files with 103 additions and 90 deletions

View File

@ -12,12 +12,12 @@ import (
"github.com/filecoin-project/specs-actors/actors/abi"
)
// TODO: Track things more actively
// FaultTracker TODO: Track things more actively
type FaultTracker interface {
CheckProvable(ctx context.Context, spt abi.RegisteredSealProof, sectors []abi.SectorID) ([]abi.SectorID, error)
}
// Returns unprovable sectors
// CheckProvable returns unprovable sectors
func (m *Manager) CheckProvable(ctx context.Context, spt abi.RegisteredSealProof, sectors []abi.SectorID) ([]abi.SectorID, error) {
var bad []abi.SectorID

View File

@ -25,20 +25,20 @@ type Provider struct {
}
func (b *Provider) AcquireSector(ctx context.Context, id abi.SectorID, existing stores.SectorFileType, allocate stores.SectorFileType, ptype stores.PathType) (stores.SectorPaths, func(), error) {
if err := os.Mkdir(filepath.Join(b.Root, stores.FTUnsealed.String()), 0755); err != nil && !os.IsExist(err) {
if err := os.Mkdir(filepath.Join(b.Root, stores.FTUnsealed.String()), 0755); err != nil && !os.IsExist(err) { // nolint
return stores.SectorPaths{}, nil, err
}
if err := os.Mkdir(filepath.Join(b.Root, stores.FTSealed.String()), 0755); err != nil && !os.IsExist(err) {
if err := os.Mkdir(filepath.Join(b.Root, stores.FTSealed.String()), 0755); err != nil && !os.IsExist(err) { // nolint
return stores.SectorPaths{}, nil, err
}
if err := os.Mkdir(filepath.Join(b.Root, stores.FTCache.String()), 0755); err != nil && !os.IsExist(err) {
if err := os.Mkdir(filepath.Join(b.Root, stores.FTCache.String()), 0755); err != nil && !os.IsExist(err) { // nolint
return stores.SectorPaths{}, nil, err
}
done := func() {}
out := stores.SectorPaths{
Id: id,
ID: id,
}
for _, fileType := range stores.PathTypes {

View File

@ -58,7 +58,7 @@ func writeTrailer(maxPieceSize int64, w *os.File, r rlepluslazy.RunIterator) err
}
func createPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialFile, error) {
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) // nolint
if err != nil {
return nil, xerrors.Errorf("openning partial file '%s': %w", path, err)
}
@ -82,7 +82,7 @@ func createPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialF
return nil
}()
if err != nil {
f.Close()
_ = f.Close()
return nil, err
}
if err := f.Close(); err != nil {
@ -93,7 +93,7 @@ func createPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialF
}
func openPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialFile, error) {
f, err := os.OpenFile(path, os.O_RDWR, 0644)
f, err := os.OpenFile(path, os.O_RDWR, 0644) // nolint
if err != nil {
return nil, xerrors.Errorf("openning partial file '%s': %w", path, err)
}
@ -161,7 +161,7 @@ func openPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialFil
return nil
}()
if err != nil {
f.Close()
_ = f.Close()
return nil, err
}

View File

@ -190,7 +190,7 @@ func (sb *Sealer) pieceCid(in []byte) (cid.Cid, error) {
return cid.Undef, xerrors.Errorf("generating piece commitment: %w", err)
}
prf.Close()
_ = prf.Close()
return pieceCID, werr()
}
@ -225,7 +225,7 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector abi.SectorID, offset s
default:
return xerrors.Errorf("acquire unsealed sector path (existing): %w", err)
}
defer pf.Close()
defer pf.Close() // nolint
allocated, err := pf.Allocated()
if err != nil {
@ -247,11 +247,11 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector abi.SectorID, offset s
}
defer srcDone()
sealed, err := os.OpenFile(srcPaths.Sealed, os.O_RDONLY, 0644)
sealed, err := os.OpenFile(srcPaths.Sealed, os.O_RDONLY, 0644) // nolint:gosec
if err != nil {
return xerrors.Errorf("opening sealed file: %w", err)
}
defer sealed.Close()
defer sealed.Close() // nolint
var at, nextat abi.PaddedPieceSize
first := true
@ -287,7 +287,7 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector abi.SectorID, offset s
{
go func() {
defer close(outWait)
defer opr.Close()
defer opr.Close() // nolint
padwriter := fr32.NewPadWriter(out)
if err != nil {
@ -377,18 +377,18 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector abi.Se
ok, err := pf.HasAllocated(offset, size)
if err != nil {
pf.Close()
_ = pf.Close()
return false, err
}
if !ok {
pf.Close()
_ = pf.Close()
return false, nil
}
f, err := pf.Reader(offset.Padded(), size.Padded())
if err != nil {
pf.Close()
_ = pf.Close()
return false, xerrors.Errorf("getting partial file reader: %w", err)
}
@ -398,7 +398,7 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector abi.Se
}
if _, err := io.CopyN(writer, upr, int64(size)); err != nil {
pf.Close()
_ = pf.Close()
return false, xerrors.Errorf("reading unsealed file: %w", err)
}
@ -416,7 +416,7 @@ func (sb *Sealer) SealPreCommit1(ctx context.Context, sector abi.SectorID, ticke
}
defer done()
e, err := os.OpenFile(paths.Sealed, os.O_RDWR|os.O_CREATE, 0644)
e, err := os.OpenFile(paths.Sealed, os.O_RDWR|os.O_CREATE, 0644) // nolint:gosec
if err != nil {
return nil, xerrors.Errorf("ensuring sealed file exists: %w", err)
}
@ -424,7 +424,7 @@ func (sb *Sealer) SealPreCommit1(ctx context.Context, sector abi.SectorID, ticke
return nil, err
}
if err := os.Mkdir(paths.Cache, 0755); err != nil {
if err := os.Mkdir(paths.Cache, 0755); err != nil { // nolint
if os.IsExist(err) {
log.Warnf("existing cache in %s; removing", paths.Cache)
@ -432,7 +432,7 @@ func (sb *Sealer) SealPreCommit1(ctx context.Context, sector abi.SectorID, ticke
return nil, xerrors.Errorf("remove existing sector cache from %s (sector %d): %w", paths.Cache, sector, err)
}
if err := os.Mkdir(paths.Cache, 0755); err != nil {
if err := os.Mkdir(paths.Cache, 0755); err != nil { // nolint:gosec
return nil, xerrors.Errorf("mkdir cache path after cleanup: %w", err)
}
} else {

View File

@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"github.com/ipfs/go-cid"
"io"
"io/ioutil"
"math/rand"
@ -16,15 +15,18 @@ import (
"testing"
"time"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
ffi "github.com/filecoin-project/filecoin-ffi"
paramfetch "github.com/filecoin-project/go-paramfetch"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-storage/storage"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/lotus/storage/sector/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/storage/sector/stores"
)
@ -443,8 +445,8 @@ func BenchmarkWriteWithAlignment(b *testing.B) {
tf, _ := ioutil.TempFile("/tmp/", "scrb-")
b.StartTimer()
ffi.WriteWithAlignment(abi.RegisteredSealProof_StackedDrg2KiBV1, rf, bt, tf, nil)
w()
ffi.WriteWithAlignment(abi.RegisteredSealProof_StackedDrg2KiBV1, rf, bt, tf, nil) // nolint:errcheck
_ = w()
}
}

View File

@ -3,7 +3,8 @@ package ffiwrapper
import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-bitfield/rle"
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/storage/sector/storiface"

View File

@ -4,14 +4,16 @@ package ffiwrapper
import (
"context"
"golang.org/x/xerrors"
"go.opencensus.io/trace"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/specs-actors/actors/abi"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/lotus/storage/sector/stores"
"go.opencensus.io/trace"
)
func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) {

View File

@ -44,8 +44,8 @@ func mt(in, out []byte, padLen int, op func(unpadded, padded []byte)) {
wg.Wait()
}
// Assumes len(in)%127==0 and len(out)%128==0
func Pad(in, out []byte) {
// Assumes len(in)%127==0 and len(out)%128==0
if len(out) > int(MTTresh) {
mt(in, out, len(out), pad)
return
@ -94,8 +94,8 @@ func pad(in, out []byte) {
}
}
// Assumes len(in)%128==0 and len(out)%127==0
func Unpad(in []byte, out []byte) {
// Assumes len(in)%128==0 and len(out)%127==0
if len(in) > int(MTTresh) {
mt(out, in, len(in), unpad)
return

View File

@ -2,18 +2,19 @@ package fr32_test
import (
"bytes"
"github.com/filecoin-project/lotus/storage/sector/fr32"
"io"
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/storage/sector/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sector/fr32"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/storage/sector/ffiwrapper"
"github.com/stretchr/testify/require"
)
func TestWriteTwoPcs(t *testing.T) {
@ -39,7 +40,7 @@ func TestWriteTwoPcs(t *testing.T) {
}
}
if _, err := tf.Seek(io.SeekStart, 0); err != nil {
if _, err := tf.Seek(io.SeekStart, 0); err != nil { // nolint:staticcheck
panic(err)
}

View File

@ -28,7 +28,7 @@ func padFFI(buf []byte) []byte {
panic(err)
}
if _, err := tf.Seek(io.SeekStart, 0); err != nil {
if _, err := tf.Seek(io.SeekStart, 0); err != nil { // nolint:staticcheck
panic(err)
}

View File

@ -24,6 +24,6 @@ func FileSize(path string) (SizeInfo, error) {
// NOTE: stat.Blocks is in 512B blocks, NOT in stat.Blksize
// See https://www.gnu.org/software/libc/manual/html_node/Attribute-Meanings.html
return SizeInfo{
int64(stat.Blocks) * 512, // NOTE: int64 cast is needed on osx
stat.Blocks * 512, // NOTE: int64 cast is needed on osx
}, nil
}

View File

@ -3,10 +3,11 @@ package sector
import (
"context"
"errors"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"io"
"net/http"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"github.com/mitchellh/go-homedir"

View File

@ -5,22 +5,22 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/filecoin-project/lotus/storage/sector/sealtasks"
logging "github.com/ipfs/go-log"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/storage/sector/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/filecoin-project/lotus/storage/sector/sealtasks"
"github.com/filecoin-project/lotus/storage/sector/stores"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/storage/sector/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sector/stores"
"github.com/google/uuid"
logging "github.com/ipfs/go-log"
"github.com/stretchr/testify/require"
)
func init() {

View File

@ -76,8 +76,8 @@ func (mgr *SectorMgr) NewSector(ctx context.Context, sector abi.SectorID) error
return nil
}
func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorId abi.SectorID, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) {
log.Warn("Add piece: ", sectorId, size, mgr.proofType)
func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorID abi.SectorID, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) {
log.Warn("Add piece: ", sectorID, size, mgr.proofType)
var b bytes.Buffer
tr := io.TeeReader(r, &b)
@ -92,12 +92,12 @@ func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorId abi.SectorID, exist
mgr.lk.Lock()
mgr.pieces[c] = b.Bytes()
ss, ok := mgr.sectors[sectorId]
ss, ok := mgr.sectors[sectorID]
if !ok {
ss = &sectorState{
state: statePacking,
}
mgr.sectors[sectorId] = ss
mgr.sectors[sectorID] = ss
}
mgr.lk.Unlock()
@ -260,7 +260,7 @@ func opFinishWait(ctx context.Context) {
func AddOpFinish(ctx context.Context) (context.Context, func()) {
done := make(chan struct{})
return context.WithValue(ctx, "opfinish", done), func() {
return context.WithValue(ctx, "opfinish", done), func() { // nolint
close(done)
}
}
@ -338,7 +338,7 @@ func (mgr *SectorMgr) StageFakeData(mid abi.ActorID) (abi.SectorID, []abi.PieceI
}
buf := make([]byte, usize)
rand.Read(buf)
_, _ = rand.Read(buf) // nolint:gosec
id := abi.SectorID{
Miner: mid,

View File

@ -323,15 +323,15 @@ func (sh *scheduler) trySched() {
// Pick best worker (shuffle in case some workers are equally as good)
rand.Shuffle(len(acceptableWindows[sqi]), func(i, j int) {
acceptableWindows[sqi][i], acceptableWindows[sqi][j] = acceptableWindows[sqi][j], acceptableWindows[sqi][i]
acceptableWindows[sqi][i], acceptableWindows[sqi][j] = acceptableWindows[sqi][j], acceptableWindows[sqi][i] // nolint:scopelint
})
sort.SliceStable(acceptableWindows[sqi], func(i, j int) bool {
wii := sh.openWindows[acceptableWindows[sqi][i]].worker
wji := sh.openWindows[acceptableWindows[sqi][j]].worker
wii := sh.openWindows[acceptableWindows[sqi][i]].worker // nolint:scopelint
wji := sh.openWindows[acceptableWindows[sqi][j]].worker // nolint:scopelint
if wii == wji {
// for the same worker prefer older windows
return acceptableWindows[sqi][i] < acceptableWindows[sqi][j]
return acceptableWindows[sqi][i] < acceptableWindows[sqi][j] // nolint:scopelint
}
wi := sh.workers[wii]

View File

@ -2,6 +2,7 @@ package stores
import (
"fmt"
"golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/actors/abi"
@ -86,7 +87,7 @@ func (t SectorFileType) All() [FileTypes]bool {
}
type SectorPaths struct {
Id abi.SectorID
ID abi.SectorID
Unsealed string
Sealed string

View File

@ -100,7 +100,7 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ
rd, err = tarutil.TarDirectory(path)
w.Header().Set("Content-Type", "application/x-tar")
} else {
rd, err = os.OpenFile(path, os.O_RDONLY, 0644)
rd, err = os.OpenFile(path, os.O_RDONLY, 0644) // nolint
w.Header().Set("Content-Type", "application/octet-stream")
}
if err != nil {

View File

@ -2,7 +2,6 @@ package stores
import (
"context"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"net/url"
gopath "path"
"sort"
@ -11,6 +10,8 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
)
@ -52,8 +53,8 @@ type SectorIndex interface { // part of storage-miner api
StorageInfo(context.Context, ID) (StorageInfo, error)
StorageReportHealth(context.Context, ID, HealthReport) error
StorageDeclareSector(ctx context.Context, storageId ID, s abi.SectorID, ft SectorFileType, primary bool) error
StorageDropSector(ctx context.Context, storageId ID, s abi.SectorID, ft SectorFileType) error
StorageDeclareSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType, primary bool) error
StorageDropSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType) error
StorageFindSector(ctx context.Context, sector abi.SectorID, ft SectorFileType, spt abi.RegisteredSealProof, allowFetch bool) ([]SectorStorageInfo, error)
StorageBestAlloc(ctx context.Context, allocate SectorFileType, spt abi.RegisteredSealProof, pathType PathType) ([]StorageInfo, error)
@ -179,7 +180,7 @@ func (i *Index) StorageReportHealth(ctx context.Context, id ID, report HealthRep
return nil
}
func (i *Index) StorageDeclareSector(ctx context.Context, storageId ID, s abi.SectorID, ft SectorFileType, primary bool) error {
func (i *Index) StorageDeclareSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType, primary bool) error {
i.lk.Lock()
defer i.lk.Unlock()
@ -192,18 +193,18 @@ loop:
d := Decl{s, fileType}
for _, sid := range i.sectors[d] {
if sid.storage == storageId {
if sid.storage == storageID {
if !sid.primary && primary {
sid.primary = true
} else {
log.Warnf("sector %v redeclared in %s", s, storageId)
log.Warnf("sector %v redeclared in %s", s, storageID)
}
continue loop
}
}
i.sectors[d] = append(i.sectors[d], &declMeta{
storage: storageId,
storage: storageID,
primary: primary,
})
}
@ -211,7 +212,7 @@ loop:
return nil
}
func (i *Index) StorageDropSector(ctx context.Context, storageId ID, s abi.SectorID, ft SectorFileType) error {
func (i *Index) StorageDropSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType) error {
i.lk.Lock()
defer i.lk.Unlock()
@ -228,7 +229,7 @@ func (i *Index) StorageDropSector(ctx context.Context, storageId ID, s abi.Secto
rewritten := make([]*declMeta, 0, len(i.sectors[d])-1)
for _, sid := range i.sectors[d] {
if sid.storage == storageId {
if sid.storage == storageID {
continue
}
@ -406,8 +407,8 @@ func (i *Index) StorageBestAlloc(ctx context.Context, allocate SectorFileType, s
}
sort.Slice(candidates, func(i, j int) bool {
iw := big.Mul(big.NewInt(int64(candidates[i].fsi.Available)), big.NewInt(int64(candidates[i].info.Weight)))
jw := big.Mul(big.NewInt(int64(candidates[j].fsi.Available)), big.NewInt(int64(candidates[j].info.Weight)))
iw := big.Mul(big.NewInt(candidates[i].fsi.Available), big.NewInt(int64(candidates[i].info.Weight)))
jw := big.Mul(big.NewInt(candidates[j].fsi.Available), big.NewInt(int64(candidates[j].info.Weight)))
return iw.GreaterThan(jw)
})

View File

@ -2,6 +2,7 @@ package stores
import (
"context"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/filecoin-project/specs-actors/actors/abi"
)

View File

@ -13,8 +13,9 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
)
type StoragePath struct {
@ -27,7 +28,7 @@ type StoragePath struct {
CanStore bool
}
// [path]/sectorstore.json
// LocalStorageMeta [path]/sectorstore.json
type LocalStorageMeta struct {
ID ID
Weight uint64 // 0 = readonly
@ -36,7 +37,7 @@ type LocalStorageMeta struct {
CanStore bool
}
// .lotusstorage/storage.json
// StorageConfig .lotusstorage/storage.json
type StorageConfig struct {
StoragePaths []LocalPath
}
@ -182,7 +183,7 @@ func (st *Local) OpenPath(ctx context.Context, p string) error {
ents, err := ioutil.ReadDir(filepath.Join(p, t.String()))
if err != nil {
if os.IsNotExist(err) {
if err := os.MkdirAll(filepath.Join(p, t.String()), 0755); err != nil {
if err := os.MkdirAll(filepath.Join(p, t.String()), 0755); err != nil { // nolint
return xerrors.Errorf("openPath mkdir '%s': %w", filepath.Join(p, t.String()), err)
}

View File

@ -3,13 +3,14 @@ package stores
import (
"context"
"encoding/json"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/google/uuid"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
)

View File

@ -3,7 +3,6 @@ package stores
import (
"context"
"encoding/json"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"io/ioutil"
"math/bits"
"mime"
@ -15,14 +14,15 @@ import (
"sort"
"sync"
"github.com/hashicorp/go-multierror"
files "github.com/ipfs/go-ipfs-files"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/storage/sector/fsutil"
"github.com/filecoin-project/lotus/storage/sector/storiface"
"github.com/filecoin-project/lotus/storage/sector/tarutil"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/storage/sector/storiface"
"github.com/filecoin-project/lotus/storage/sector/tarutil"
"github.com/hashicorp/go-multierror"
files "github.com/ipfs/go-ipfs-files"
"golang.org/x/xerrors"
)
var FetchTempSubdir = "fetching"
@ -161,7 +161,7 @@ func tempFetchDest(spath string, create bool) (string, error) {
st, b := filepath.Split(spath)
tempdir := filepath.Join(st, FetchTempSubdir)
if create {
if err := os.MkdirAll(tempdir, 0755); err != nil {
if err := os.MkdirAll(tempdir, 0755); err != nil { // nolint
return "", xerrors.Errorf("creating temp fetch dir: %w", err)
}
}
@ -246,7 +246,7 @@ func (r *Remote) fetch(ctx context.Context, url, outname string) error {
if err != nil {
return xerrors.Errorf("do request: %w", err)
}
defer resp.Body.Close()
defer resp.Body.Close() // nolint
if resp.StatusCode != 200 {
return xerrors.Errorf("non-200 code: %d", resp.StatusCode)
@ -332,7 +332,7 @@ func (r *Remote) deleteFromRemote(ctx context.Context, url string) error {
if err != nil {
return xerrors.Errorf("do request: %w", err)
}
defer resp.Body.Close()
defer resp.Body.Close() // nolint
if resp.StatusCode != 200 {
return xerrors.Errorf("non-200 code: %d", resp.StatusCode)
@ -398,7 +398,7 @@ func (r *Remote) FsStat(ctx context.Context, id ID) (fsutil.FsStat, error) {
return fsutil.FsStat{}, xerrors.Errorf("decoding fsstat: %w", err)
}
defer resp.Body.Close()
defer resp.Body.Close() // nolint
return out, nil
}

View File

@ -33,7 +33,7 @@ func move(from, to string) error {
// can do better
var errOut bytes.Buffer
cmd := exec.Command("/usr/bin/env", "mv", "-t", toDir, from)
cmd := exec.Command("/usr/bin/env", "mv", "-t", toDir, from) // nolint
cmd.Stderr = &errOut
if err := cmd.Run(); err != nil {
return xerrors.Errorf("exec mv (stderr: %s): %w", strings.TrimSpace(errOut.String()), err)

View File

@ -28,8 +28,8 @@ type WorkerStats struct {
MemUsedMin uint64
MemUsedMax uint64
GpuUsed bool
CpuUse uint64
GpuUsed bool // nolint
CpuUse uint64 // nolint
}
type WorkerJob struct {

View File

@ -2,19 +2,20 @@ package tarutil
import (
"archive/tar"
"golang.org/x/xerrors"
"io"
"io/ioutil"
"os"
"path/filepath"
"golang.org/x/xerrors"
logging "github.com/ipfs/go-log/v2"
)
var log = logging.Logger("tarutil") // nolint
func ExtractTar(body io.Reader, dir string) error {
if err := os.MkdirAll(dir, 0755); err != nil {
if err := os.MkdirAll(dir, 0755); err != nil { // nolint
return xerrors.Errorf("mkdir: %w", err)
}