Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/desync/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ func runCat(ctx context.Context, opt catOptions, args []string) error {
)
if len(args) == 2 {
outFileName := args[1]
outFile, err = os.Create(outFileName)
f, err := os.Create(outFileName)
if err != nil {
return err
}
defer f.Close()
outFile = f
} else {
outFile = stdout
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/desync/chunkserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func runChunkServer(ctx context.Context, opt chunkServerOptions, args []string)
// Wrapper for http.HandlerFunc to add logging for requests (and response codes)
func withLog(h http.Handler, log *log.Logger) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
lrw := &loggingResponseWriter{ResponseWriter: w}
lrw := &loggingResponseWriter{ResponseWriter: w, statusCode: http.StatusOK}
h.ServeHTTP(lrw, r)
log.Printf("Client: %s, Request: %s %s, Response: %d", r.RemoteAddr, r.Method, r.RequestURI, lrw.statusCode)
}
Expand All @@ -178,7 +178,7 @@ func chunkServerStore(opt chunkServerOptions) (desync.Store, error) {
}
stores, cache, err = readStoreFile(opt.storeFile)
if err != nil {
return nil, errors.Wrapf(err, "failed to read store-file '%s'", err)
return nil, errors.Wrapf(err, "failed to read store-file '%s'", opt.storeFile)
}
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/desync/chunkserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ func startChunkServer(t *testing.T, args ...string) (string, context.CancelFunc)
cmd := newChunkServerCommand(ctx)
cmd.SetArgs(append(args, "-l", addr))
go func() {
_, err = cmd.ExecuteC()
require.NoError(t, err)
if _, err := cmd.ExecuteC(); err != nil && ctx.Err() == nil {
t.Errorf("chunk server error: %v", err)
}
}()

// Wait a little for the server to start
Expand Down
2 changes: 1 addition & 1 deletion cmd/desync/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func runConfig(ctx context.Context, write bool) error {
if err != nil {
return err
}
var w io.Writer = os.Stderr
var w io.Writer = os.Stdout
if write {
if err = os.MkdirAll(filepath.Dir(cfgFile), 0755); err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions cmd/desync/indexserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ func startIndexServer(t *testing.T, args ...string) (string, context.CancelFunc)
cmd := newIndexServerCommand(ctx)
cmd.SetArgs(append(args, "-l", addr))
go func() {
_, err = cmd.ExecuteC()
require.NoError(t, err)
if _, err := cmd.ExecuteC(); err != nil && ctx.Err() == nil {
t.Errorf("index server error: %v", err)
}
}()

// Wait a little for the server to start
Expand Down
2 changes: 1 addition & 1 deletion cmd/desync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func runInfo(ctx context.Context, opt infoOptions, args []string) error {
fmt.Println("Chunk size avg:", results.ChunkSizeAvg)
fmt.Println("Chunk size max:", results.ChunkSizeMax)
default:
return fmt.Errorf("unsupported output format '%s", opt.printFormat)
return fmt.Errorf("unsupported output format %q", opt.printFormat)
}
return nil
}
4 changes: 3 additions & 1 deletion cmd/desync/inspectchunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ func runInspectChunks(ctx context.Context, opt inspectChunksOptions, args []stri
)
if len(args) == 2 {
outFileName := args[1]
outFile, err = os.Create(outFileName)
f, err := os.Create(outFileName)
if err != nil {
return err
}
defer f.Close()
outFile = f
} else {
outFile = stdout
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/desync/mount-index.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func mountIndexStore(opt mountIndexOptions) (desync.Store, error) {
}
stores, cache, err = readStoreFile(opt.storeFile)
if err != nil {
return nil, errors.Wrapf(err, "failed to read store-file '%s'", err)
return nil, errors.Wrapf(err, "failed to read store-file '%s'", opt.storeFile)
}
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/desync/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ func runPrune(ctx context.Context, opt pruneOptions, args []string) error {
for {
var a string
fmt.Printf("[y/N]: ")
fmt.Fscanln(os.Stdin, &a)
if _, err := fmt.Fscanln(os.Stdin, &a); err != nil {
return err
}
switch a {
case "y", "Y":
break ask
Expand Down
2 changes: 1 addition & 1 deletion cmd/desync/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func indexStoreFromLocation(location string, cmdOpt cmdStoreOptions) (desync.Ind
lookup = minio.BucketLookupPath
case "", "auto":
default:
return nil, "", fmt.Errorf("unknown S3 bucket lookup type: %q", s)
return nil, "", fmt.Errorf("unknown S3 bucket lookup type: %q", ls)
}
s, err = desync.NewS3IndexStore(&p, s3Creds, region, opt, lookup)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions cmd/desync/verifyindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func TestVerifyIndexCommand(t *testing.T) {
stderr = b
_, err := verifyIndex.ExecuteC()
require.NoError(t, err)
require.Contains(t, b.String(), "")

// Do the same for blob2
verifyIndex = newVerifyIndexCommand(context.Background())
Expand All @@ -24,7 +23,6 @@ func TestVerifyIndexCommand(t *testing.T) {
stderr = b
_, err = verifyIndex.ExecuteC()
require.NoError(t, err)
require.Contains(t, b.String(), "")

// Run again against the wrong blob
verifyIndex = newVerifyIndexCommand(context.Background())
Expand Down