Fix bugs, resource leaks, and test issues in cmd/desync#310
Merged
Conversation
- store.go: Fix wrong variable in S3 bucket lookup error message (printed nil IndexStore instead of the lookup string) - chunkserver.go, mount-index.go: Fix errors.Wrapf passing err as format arg instead of the store-file path - info.go: Fix missing closing quote in unsupported format error string - cat.go, inspectchunks.go: Close output file when writing to disk - chunkserver.go: Initialize loggingResponseWriter statusCode to 200 so implicit WriteHeader is logged correctly - config.go: Write config JSON to stdout instead of stderr in read mode - prune.go: Check error from fmt.Fscanln to prevent infinite loop on closed stdin - chunkserver_test.go, indexserver_test.go: Replace require.NoError (which calls t.FailNow) with t.Errorf in server goroutines - verifyindex_test.go: Remove no-op assertions that check for empty string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
indexStoreFromLocationprinted the nilIndexStorevariablesinstead of the lookup stringls(the equivalent code instoreFromLocationwas correct)errors.Wrapfpassingerras the format argument instead ofopt.storeFile— the error was printed twice while the filename was lost'%s→%q)os.Createwas called but the file was never closedloggingResponseWriter.statusCodetohttp.StatusOKso handlers that write a body without explicitly callingWriteHeader()log 200 instead of 0fmt.Fscanlnto prevent infinite loop when stdin is closedrequire.NoError(callst.FailNow) witht.Errorfin server goroutines, per project convention (PR Do not call t.Fatal() from non-main goroutines #291)require.Contains(t, b.String(), "")assertions that always passTest plan
go build ./cmd/desyncsucceedsgo test ./...passes