mirror of
https://github.com/kopia/kopia.git
synced 2025-12-23 22:57:50 -05:00
chore(ci): enable wsl_v5:{assign,expr} linter settings (#4982)
Enable wsl_v5 settings: - assign - expr
This commit is contained in:
@@ -82,9 +82,6 @@ linters:
|
||||
locale: US
|
||||
wsl_v5:
|
||||
allow-whole-block: true
|
||||
disable:
|
||||
- assign
|
||||
- expr
|
||||
|
||||
default: all
|
||||
disable:
|
||||
|
||||
@@ -260,6 +260,7 @@ func (c *App) setup(app *kingpin.Application) {
|
||||
|
||||
_ = app.Flag("help-full", "Show help for all commands, including hidden").Action(func(pc *kingpin.ParseContext) error {
|
||||
_ = app.UsageForContextWithTemplate(pc, 0, kingpin.DefaultUsageTemplate)
|
||||
|
||||
c.exitWithError(nil)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -55,6 +55,7 @@ func (c *commandContentVerify) run(ctx context.Context, rep repo.DirectRepositor
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
c.getTotalContentCount(subctx, rep, &totalCount)
|
||||
}()
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ func (c *commandPolicyEdit) run(ctx context.Context, rep repo.RepositoryWriter)
|
||||
|
||||
func prettyJSON(v *policy.Policy) string {
|
||||
var b bytes.Buffer
|
||||
|
||||
e := json.NewEncoder(&b)
|
||||
e.SetIndent("", " ")
|
||||
e.Encode(v) //nolint:errcheck,errchkjson
|
||||
|
||||
@@ -19,6 +19,7 @@ func TestSnapshotList(t *testing.T) {
|
||||
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
|
||||
srcdir := testutil.TempDirectory(t)
|
||||
@@ -86,6 +87,7 @@ func TestSnapshotListWithSameFileInMultipleSnapshots(t *testing.T) {
|
||||
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
|
||||
srcdir := testutil.TempDirectory(t)
|
||||
|
||||
@@ -109,6 +109,7 @@ func (c *commandSnapshotMigrate) run(ctx context.Context, destRepo repo.Reposito
|
||||
uploader := upload.NewUploader(destRepo)
|
||||
uploader.Progress = c.svc.getProgress()
|
||||
activeUploaders[s] = uploader
|
||||
|
||||
mu.Unlock()
|
||||
|
||||
wg.Add(1)
|
||||
|
||||
@@ -20,6 +20,7 @@ func TestSnapshotPin(t *testing.T) {
|
||||
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
|
||||
srcdir := testutil.TempDirectory(t)
|
||||
|
||||
@@ -34,6 +34,7 @@ func (c *App) onTerminate(f func()) {
|
||||
|
||||
case <-s:
|
||||
}
|
||||
|
||||
f()
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@ func (jw *JSONWriter) TimeField(key string, value time.Time) {
|
||||
// appendPaddedInt appends an integer with zero-padding to the buffer.
|
||||
func (jw *JSONWriter) appendPaddedInt(value int64, width int) {
|
||||
var numBuf [64]byte
|
||||
|
||||
numStr := strconv.AppendInt(numBuf[:0], value, decimal)
|
||||
numLen := len(numStr)
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ func TestLog(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "test message", logEntry["m"])
|
||||
@@ -88,6 +89,7 @@ func TestLog(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "test message", logEntry["m"])
|
||||
@@ -126,6 +128,7 @@ func TestLog1(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "processing item", logEntry["m"])
|
||||
@@ -165,6 +168,7 @@ func TestLog1(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.message, logEntry["m"])
|
||||
@@ -192,6 +196,7 @@ func TestLog2(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "processing item", logEntry["m"])
|
||||
@@ -219,6 +224,7 @@ func TestLog3(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "processing item", logEntry["m"])
|
||||
@@ -248,6 +254,7 @@ func TestLog4(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "processing item", logEntry["m"])
|
||||
@@ -279,6 +286,7 @@ func TestLog5(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "processing item", logEntry["m"])
|
||||
@@ -312,6 +320,7 @@ func TestLog6(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "processing item", logEntry["m"])
|
||||
@@ -345,6 +354,7 @@ func TestEmit(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "custom entry", logEntry["message"])
|
||||
@@ -377,6 +387,7 @@ func TestEmit(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "custom entry", logEntry["message"])
|
||||
@@ -424,12 +435,14 @@ func TestLoggerMultipleLogs(t *testing.T) {
|
||||
|
||||
// Check first entry
|
||||
var entry1 map[string]any
|
||||
|
||||
err := json.Unmarshal([]byte(lines[0]), &entry1)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "first message", entry1["m"])
|
||||
|
||||
// Check second entry
|
||||
var entry2 map[string]any
|
||||
|
||||
err = json.Unmarshal([]byte(lines[1]), &entry2)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "second message", entry2["m"])
|
||||
@@ -437,6 +450,7 @@ func TestLoggerMultipleLogs(t *testing.T) {
|
||||
|
||||
// Check third entry
|
||||
var entry3 map[string]any
|
||||
|
||||
err = json.Unmarshal([]byte(lines[2]), &entry3)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "third message", entry3["m"])
|
||||
@@ -461,6 +475,7 @@ func TestLoggerErrorHandling(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "error test", logEntry["m"])
|
||||
@@ -483,6 +498,7 @@ func TestLoggerErrorHandling(t *testing.T) {
|
||||
require.NotEmpty(t, captured)
|
||||
|
||||
var logEntry map[string]any
|
||||
|
||||
err := json.Unmarshal(captured, &logEntry)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "error test", logEntry["m"])
|
||||
|
||||
@@ -357,6 +357,7 @@ func (c *Comparer) compareFiles(ctx context.Context, f1, f2 fs.File, fname strin
|
||||
}
|
||||
|
||||
var args []string
|
||||
|
||||
args = append(args, c.DiffArguments...)
|
||||
args = append(args, oldName, newName)
|
||||
|
||||
|
||||
@@ -550,11 +550,13 @@ func TestGetTwoLatestSnapshots(t *testing.T) {
|
||||
intermediateSnapshotManifestID := mustSaveSnapshot(t, env.RepositoryWriter, manifests["intermediate_snapshot"])
|
||||
|
||||
var expectedManifestIDs []manifest.ID
|
||||
|
||||
expectedManifestIDs = append(expectedManifestIDs, initialSnapshotManifestID, intermediateSnapshotManifestID)
|
||||
|
||||
secondLastSnapshot, lastSnapshot, err := diff.GetTwoLatestSnapshotsForASource(ctx, env.RepositoryWriter, snapshotSrc)
|
||||
|
||||
var gotManifestIDs []manifest.ID
|
||||
|
||||
gotManifestIDs = append(gotManifestIDs, secondLastSnapshot.ID, lastSnapshot.ID)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -161,6 +161,7 @@ func (b *WriteBuffer) Dup() *WriteBuffer {
|
||||
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
dup.alloc = b.alloc
|
||||
dup.inner = FromSlice(b.inner.ToByteSlice())
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func VerifyAndStrip(input gather.Bytes, secret []byte, output *gather.WriteBuffe
|
||||
}
|
||||
|
||||
var sigBuf, actualSignature [sha256.Size]byte
|
||||
|
||||
validSignature := h.Sum(sigBuf[:0])
|
||||
|
||||
n, err := r.Read(actualSignature[:])
|
||||
|
||||
@@ -31,6 +31,7 @@ func TestGetBuffer(t *testing.T) {
|
||||
func TestReleaseBuffer(t *testing.T) {
|
||||
buf := iocopy.GetBuffer()
|
||||
iocopy.ReleaseBuffer(buf)
|
||||
|
||||
buf2 := iocopy.GetBuffer()
|
||||
require.Equal(t, &buf[0], &buf2[0], "Buffer was not recycled after ReleaseBuffer")
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
func TestCounter_Nil(t *testing.T) {
|
||||
var e *metrics.Registry
|
||||
|
||||
cnt := e.CounterInt64("aaa", "bbb", nil)
|
||||
require.Nil(t, cnt)
|
||||
cnt.Add(33)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
func TestDurationDistribution_Nil(t *testing.T) {
|
||||
var e *metrics.Registry
|
||||
|
||||
dist := e.DurationDistribution("aaa", "bbb", metrics.IOLatencyThresholds, nil)
|
||||
require.Nil(t, dist)
|
||||
dist.Observe(time.Second)
|
||||
@@ -20,6 +21,7 @@ func TestDurationDistribution_Nil(t *testing.T) {
|
||||
|
||||
func TestSizeDistribution_Nil(t *testing.T) {
|
||||
var e *metrics.Registry
|
||||
|
||||
cnt := e.SizeDistribution("aaa", "bbb", metrics.ISOBytesThresholds, nil)
|
||||
require.Nil(t, cnt)
|
||||
cnt.Observe(333)
|
||||
|
||||
@@ -154,6 +154,7 @@ func OnNthCompletion(n int, callback CallbackFunc) CallbackFunc {
|
||||
|
||||
n--
|
||||
call := n == 0
|
||||
|
||||
mu.Unlock()
|
||||
|
||||
if call {
|
||||
|
||||
@@ -167,6 +167,7 @@ func (s *Server) Session(srv grpcapi.KopiaRepository_SessionServer) error {
|
||||
func (s *Server) handleSessionRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, usernameAtHostname string, req *grpcapi.SessionRequest, respond func(*grpcapi.SessionResponse)) {
|
||||
if req.GetTraceContext() != nil {
|
||||
var tc propagation.TraceContext
|
||||
|
||||
ctx = tc.Extract(ctx, propagation.MapCarrier(req.GetTraceContext()))
|
||||
}
|
||||
|
||||
|
||||
@@ -976,6 +976,7 @@ func (s *Server) runSnapshotTask(ctx context.Context, src snapshot.SourceInfo, i
|
||||
}
|
||||
|
||||
var result notifydata.ManifestWithError
|
||||
|
||||
result.Manifest.Source = src
|
||||
|
||||
defer s.endUpload(ctx, src, &result)
|
||||
|
||||
@@ -134,6 +134,7 @@ func TestTimerConcurrentStop(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
timer.Stop()
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -103,11 +103,12 @@ func TestGetBlobVersions(t *testing.T) {
|
||||
latestData = "latest version"
|
||||
)
|
||||
|
||||
dataBlobs := []string{originalData, updatedData, latestData}
|
||||
|
||||
const blobName = "TestGetBlobVersions"
|
||||
|
||||
blobID := blob.ID(blobName)
|
||||
dataBlobs := []string{originalData, updatedData, latestData}
|
||||
dataTimestamps, err := putBlobs(ctx, st, blobID, dataBlobs)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
pastPIT := dataTimestamps[0].Add(-1 * time.Second)
|
||||
@@ -162,6 +163,7 @@ func TestGetBlobVersions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
var tmp gather.WriteBuffer
|
||||
|
||||
err = st.GetBlob(ctx, blobID, 0, -1, &tmp)
|
||||
require.ErrorIs(t, err, tt.expectedError)
|
||||
require.Equal(t, tt.expectedBlobData, string(tmp.ToByteSlice()))
|
||||
@@ -212,6 +214,7 @@ func TestGetBlobVersionsWithDeletion(t *testing.T) {
|
||||
dataBlobs := []string{originalData, updatedData}
|
||||
|
||||
const blobName = "TestGetBlobVersionsWithDeletion"
|
||||
|
||||
blobID := blob.ID(blobName)
|
||||
dataTimestamps, err := putBlobs(ctx, st, blobID, dataBlobs)
|
||||
require.NoError(t, err)
|
||||
@@ -235,6 +238,7 @@ func TestGetBlobVersionsWithDeletion(t *testing.T) {
|
||||
require.Equal(t, 1, count)
|
||||
|
||||
var tmp gather.WriteBuffer
|
||||
|
||||
err = st.GetBlob(ctx, blobID, 0, -1, &tmp)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, updatedData, string(tmp.ToByteSlice()))
|
||||
|
||||
@@ -105,6 +105,7 @@ func TestGetBlobVersions(t *testing.T) {
|
||||
dataBlobs := []string{originalData, updatedData, latestData}
|
||||
|
||||
const blobName = "TestGetBlobVersions"
|
||||
|
||||
blobID := blob.ID(blobName)
|
||||
dataTimestamps, err := putBlobs(ctx, st, blobID, dataBlobs)
|
||||
require.NoError(t, err)
|
||||
@@ -161,6 +162,7 @@ func TestGetBlobVersions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
var tmp gather.WriteBuffer
|
||||
|
||||
err = st.GetBlob(ctx, blobID, 0, -1, &tmp)
|
||||
require.ErrorIs(t, err, tt.expectedError)
|
||||
require.Equal(t, tt.expectedBlobData, string(tmp.ToByteSlice()))
|
||||
@@ -206,12 +208,11 @@ func TestGetBlobVersionsWithDeletion(t *testing.T) {
|
||||
const (
|
||||
originalData = "original"
|
||||
updatedData = "some update"
|
||||
blobName = "TestGetBlobVersionsWithDeletion"
|
||||
)
|
||||
|
||||
dataBlobs := []string{originalData, updatedData}
|
||||
|
||||
const blobName = "TestGetBlobVersionsWithDeletion"
|
||||
blobID := blob.ID(blobName)
|
||||
dataBlobs := []string{originalData, updatedData}
|
||||
dataTimestamps, err := putBlobs(ctx, st, blobID, dataBlobs)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -234,6 +235,7 @@ func TestGetBlobVersionsWithDeletion(t *testing.T) {
|
||||
require.Equal(t, 1, count)
|
||||
|
||||
var tmp gather.WriteBuffer
|
||||
|
||||
err = st.GetBlob(ctx, blobID, 0, -1, &tmp)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, updatedData, string(tmp.ToByteSlice()))
|
||||
|
||||
@@ -361,6 +361,7 @@ func New(ctx context.Context, opt *Options, isCreate bool) (blob.Storage, error)
|
||||
fingerprintHexString := hex.EncodeToString(fingerprintBytes[:])
|
||||
|
||||
var cli http.Client
|
||||
|
||||
cli.Transport = &http.Transport{
|
||||
TLSClientConfig: tlsutil.TLSConfigTrustingSingleCertificate(fingerprintHexString),
|
||||
}
|
||||
|
||||
@@ -663,7 +663,9 @@ func randLongHex(tb testing.TB, length int) string {
|
||||
b := make([]byte, byteLength)
|
||||
|
||||
rMu.Lock()
|
||||
|
||||
n, err := r.Read(b)
|
||||
|
||||
rMu.Unlock()
|
||||
|
||||
require.NoError(tb, err)
|
||||
|
||||
@@ -50,6 +50,7 @@ func TestThrottlingSemaphore(t *testing.T) {
|
||||
mu.Lock()
|
||||
|
||||
concurrency--
|
||||
|
||||
mu.Unlock()
|
||||
|
||||
s.Release()
|
||||
|
||||
@@ -85,6 +85,7 @@ func (s *contentManagerSuite) TestContentManagerEmptyFlush(t *testing.T) {
|
||||
bm := s.newTestContentManager(t, st)
|
||||
|
||||
defer bm.CloseShared(ctx)
|
||||
|
||||
bm.Flush(ctx)
|
||||
|
||||
if got, want := len(data), 0; got != want {
|
||||
@@ -99,6 +100,7 @@ func (s *contentManagerSuite) TestContentZeroBytes1(t *testing.T) {
|
||||
bm := s.newTestContentManager(t, st)
|
||||
|
||||
defer bm.CloseShared(ctx)
|
||||
|
||||
contentID := writeContentAndVerify(ctx, t, bm, []byte{})
|
||||
bm.Flush(ctx)
|
||||
|
||||
@@ -1054,6 +1056,7 @@ func (s *contentManagerSuite) TestParallelWrites(t *testing.T) {
|
||||
workerLock.RLock()
|
||||
|
||||
workerWritten[workerID] = append(workerWritten[workerID], id)
|
||||
|
||||
workerLock.RUnlock()
|
||||
}
|
||||
}()
|
||||
@@ -1118,6 +1121,7 @@ func (s *contentManagerSuite) TestFlushResumesWriters(t *testing.T) {
|
||||
|
||||
bm := s.newTestContentManagerWithTweaks(t, fs, nil)
|
||||
defer bm.CloseShared(ctx)
|
||||
|
||||
first := writeContentAndVerify(ctx, t, bm, []byte{1, 2, 3})
|
||||
|
||||
var second ID
|
||||
@@ -1641,7 +1645,9 @@ func (s *contentManagerSuite) TestIterateContents(t *testing.T) {
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
|
||||
got[ci.ContentID] = true
|
||||
|
||||
mu.Unlock()
|
||||
|
||||
return nil
|
||||
@@ -1977,6 +1983,7 @@ func (s *contentManagerSuite) verifyVersionCompat(t *testing.T, writeVersion for
|
||||
// now open one more manager
|
||||
mgr = s.newTestContentManager(t, st)
|
||||
defer mgr.CloseShared(ctx)
|
||||
|
||||
verifyContentManagerDataSet(ctx, t, mgr, dataSet)
|
||||
}
|
||||
|
||||
@@ -2211,6 +2218,7 @@ func (s *contentManagerSuite) TestPrefetchContent(t *testing.T) {
|
||||
})
|
||||
|
||||
defer bm.CloseShared(ctx)
|
||||
|
||||
bm.Flush(ctx)
|
||||
|
||||
// write 6 x 6 MB content in 2 blobs.
|
||||
|
||||
@@ -92,6 +92,7 @@ func (b *indexV1) entryToInfoStruct(contentID ID, data []byte, result *Info) err
|
||||
result.Deleted = data[12]&0x80 != 0 //nolint:mnd
|
||||
|
||||
const packOffsetMask = 1<<31 - 1
|
||||
|
||||
result.PackOffset = decodeBigEndianUint32(data[12:]) & packOffsetMask
|
||||
result.PackedLength = decodeBigEndianUint32(data[16:])
|
||||
result.OriginalLength = result.PackedLength - b.v1PerContentOverhead
|
||||
|
||||
@@ -166,6 +166,7 @@ func TestMergedGetInfoError(t *testing.T) {
|
||||
m := Merged{failingIndex{nil, someError}}
|
||||
|
||||
var info Info
|
||||
|
||||
ok, err := m.GetInfo(mustParseID(t, "xabcdef"), &info)
|
||||
require.ErrorIs(t, err, someError)
|
||||
require.False(t, ok)
|
||||
|
||||
@@ -172,6 +172,7 @@ func (r *ReedSolomonCrcECC) Encrypt(input gather.Bytes, _ []byte, output *gather
|
||||
// Allocate space for the input + padding
|
||||
var inputBuffer gather.WriteBuffer
|
||||
defer inputBuffer.Close()
|
||||
|
||||
inputBytes := inputBuffer.MakeContiguous(dataSizeInBlock * sizes.Blocks)
|
||||
|
||||
binary.BigEndian.PutUint32(inputBytes[:lengthSize], uint32(input.Length())) //nolint:gosec
|
||||
@@ -185,13 +186,16 @@ func (r *ReedSolomonCrcECC) Encrypt(input gather.Bytes, _ []byte, output *gather
|
||||
// Compute and store ECC + checksum
|
||||
|
||||
var crcBuffer [crcSize]byte
|
||||
|
||||
crcBytes := crcBuffer[:]
|
||||
|
||||
var eccBuffer gather.WriteBuffer
|
||||
defer eccBuffer.Close()
|
||||
|
||||
eccBytes := eccBuffer.MakeContiguous(paritySizeInBlock)
|
||||
|
||||
var maxShards [256][]byte
|
||||
|
||||
shards := maxShards[:sizes.DataShards+sizes.ParityShards]
|
||||
|
||||
inputPos := 0
|
||||
@@ -255,6 +259,7 @@ func (r *ReedSolomonCrcECC) Decrypt(input gather.Bytes, _ []byte, output *gather
|
||||
// Allocate space for the input + padding
|
||||
var inputBuffer gather.WriteBuffer
|
||||
defer inputBuffer.Close()
|
||||
|
||||
inputBytes := inputBuffer.MakeContiguous((dataPlusCrcSizeInBlock + parityPlusCrcSizeInBlock) * sizes.Blocks)
|
||||
|
||||
copied := input.AppendToSlice(inputBytes[:0])
|
||||
@@ -268,6 +273,7 @@ func (r *ReedSolomonCrcECC) Decrypt(input gather.Bytes, _ []byte, output *gather
|
||||
dataBytes := inputBytes[parityPlusCrcSizeInBlock*sizes.Blocks:]
|
||||
|
||||
var maxShards [256][]byte
|
||||
|
||||
shards := maxShards[:sizes.DataShards+sizes.ParityShards]
|
||||
|
||||
dataPos := 0
|
||||
|
||||
@@ -26,6 +26,7 @@ func (e aes256GCMHmacSha256) aeadForContent(contentID []byte) (cipher.AEAD, erro
|
||||
//nolint:forcetypeassert
|
||||
h := e.hmacPool.Get().(hash.Hash)
|
||||
defer e.hmacPool.Put(h)
|
||||
|
||||
h.Reset()
|
||||
|
||||
if _, err := h.Write(contentID); err != nil {
|
||||
@@ -33,6 +34,7 @@ func (e aes256GCMHmacSha256) aeadForContent(contentID []byte) (cipher.AEAD, erro
|
||||
}
|
||||
|
||||
var hashBuf [32]byte
|
||||
|
||||
key := h.Sum(hashBuf[:0])
|
||||
|
||||
c, err := aes.NewCipher(key)
|
||||
|
||||
@@ -34,6 +34,7 @@ func (e chacha20poly1305hmacSha256Encryptor) aeadForContent(contentID []byte) (c
|
||||
}
|
||||
|
||||
var hashBuf [32]byte
|
||||
|
||||
key := h.Sum(hashBuf[:0])
|
||||
|
||||
//nolint:wrapcheck
|
||||
|
||||
@@ -144,6 +144,7 @@ func verifyCiphertextSamples(t *testing.T, masterKey, contentID, payload []byte,
|
||||
func() {
|
||||
var v gather.WriteBuffer
|
||||
defer v.Close()
|
||||
|
||||
require.NoError(t, enc.Encrypt(gather.FromSlice(payload), contentID, &v))
|
||||
|
||||
t.Errorf("missing ciphertext sample for %q: %q,", encryptionAlgo, hex.EncodeToString(payload))
|
||||
|
||||
@@ -38,6 +38,7 @@ func (s *formatSpecificTestSuite) TestMaintenanceSafety(t *testing.T) {
|
||||
fmt.Fprintf(ow, "hello world")
|
||||
|
||||
var err error
|
||||
|
||||
objectID, err = ow.Result()
|
||||
|
||||
return err
|
||||
|
||||
@@ -164,7 +164,9 @@ func (m *committedManifestManager) loadCommittedContentsLocked(ctx context.Conte
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
|
||||
manifests[ci.ContentID] = man
|
||||
|
||||
mu.Unlock()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -208,6 +208,7 @@ func TestManifestInitCorruptedBlock(t *testing.T) {
|
||||
}{
|
||||
{"GetRaw", func() error {
|
||||
var raw json.RawMessage
|
||||
|
||||
_, err := mgr.Get(ctx, "anything", &raw)
|
||||
|
||||
return err
|
||||
|
||||
@@ -159,6 +159,7 @@ func (w *objectWriter) flushBufferLocked() error {
|
||||
|
||||
// acquire write semaphore
|
||||
w.asyncWritesSemaphore <- struct{}{}
|
||||
|
||||
w.asyncWritesWG.Add(1)
|
||||
|
||||
asyncBuf := gather.NewWriteBuffer()
|
||||
|
||||
@@ -467,6 +467,7 @@ func upgradeLockMonitor(
|
||||
m.RUnlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
m.RUnlock()
|
||||
|
||||
// upgrade the lock and verify again in-case someone else won the race to refresh
|
||||
|
||||
@@ -550,6 +550,7 @@ func TestInitializeWithNoRetention(t *testing.T) {
|
||||
// are not supplied.
|
||||
var b gather.WriteBuffer
|
||||
defer b.Close()
|
||||
|
||||
require.NoError(t, env.RepositoryWriter.BlobStorage().GetBlob(ctx, format.KopiaBlobCfgBlobID, 0, -1, &b))
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ func expectSuccessfulEstimation(
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
|
||||
estimator.StartEstimation(ctx, func(fc, ts int64) {
|
||||
filesCount = fc
|
||||
totalFileSize = ts
|
||||
|
||||
@@ -1109,6 +1109,7 @@ func (w *mockLogger) Write(p []byte) (int, error) {
|
||||
parts := strings.SplitN(strings.TrimSpace(string(p)), "\t", 2)
|
||||
|
||||
var la loggedAction
|
||||
|
||||
la.msg = parts[0]
|
||||
|
||||
if len(parts) == 2 {
|
||||
|
||||
@@ -944,6 +944,7 @@ func TestRestoreByPathWithoutTarget(t *testing.T) {
|
||||
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
|
||||
srcdir := testutil.TempDirectory(t)
|
||||
|
||||
@@ -147,6 +147,7 @@ func TestServerStart(t *testing.T) {
|
||||
|
||||
// make sure root payload is valid JSON for the directory.
|
||||
var dummy map[string]any
|
||||
|
||||
err = json.Unmarshal(rootPayload, &dummy)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -442,6 +443,7 @@ func TestServerScheduling(t *testing.T) {
|
||||
emptyDir2 := testutil.TempDirectory(t)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir, "--override-hostname=fake-hostname", "--override-username=fake-username")
|
||||
|
||||
e.RunAndExpectSuccess(t, "snapshot", "create", emptyDir1)
|
||||
|
||||
@@ -786,6 +786,7 @@ func getShallowInfo(t *testing.T, srp string) (string, os.FileInfo) {
|
||||
t.Helper()
|
||||
|
||||
const ENTRYTYPES = 3
|
||||
|
||||
shallowinfos := make([]os.FileInfo, ENTRYTYPES)
|
||||
errors := make([]error, ENTRYTYPES)
|
||||
paths := make([]string, ENTRYTYPES)
|
||||
|
||||
@@ -383,6 +383,7 @@ func mustReadEnvFile(t *testing.T, fname string) map[string]string {
|
||||
verifyNoError(t, err)
|
||||
|
||||
defer f.Close()
|
||||
|
||||
s := bufio.NewScanner(f)
|
||||
|
||||
m := map[string]string{}
|
||||
|
||||
@@ -515,6 +515,7 @@ func TestSnapshotCreateWithIgnore(t *testing.T) {
|
||||
}
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
e.RunAndExpectSuccess(t, "snapshot", "create", baseDir)
|
||||
sources := clitestutil.ListSnapshotsAndExpectSuccess(t, e)
|
||||
@@ -557,8 +558,8 @@ func TestSnapshotCreateAllWithManualSnapshot(t *testing.T) {
|
||||
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir1)
|
||||
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir2)
|
||||
|
||||
@@ -585,6 +586,7 @@ func TestSnapshotCreateWithStdinStream(t *testing.T) {
|
||||
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
|
||||
|
||||
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
|
||||
|
||||
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
|
||||
|
||||
// Create a temporary pipe file with test data
|
||||
|
||||
@@ -302,6 +302,7 @@ func (th *TestHarness) GetDirsToLog(ctx context.Context) []string {
|
||||
}
|
||||
|
||||
var dirList []string
|
||||
|
||||
dirList = append(dirList,
|
||||
th.dataRepoPath, // repo under test base dir
|
||||
th.metaRepoPath, // metadata repository base dir
|
||||
|
||||
@@ -303,6 +303,7 @@ func TestPathLockRace(t *testing.T) {
|
||||
}
|
||||
|
||||
counter++
|
||||
|
||||
lock.Unlock()
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ func TestServerControlSocketActivatedTooManyFDs(t *testing.T) {
|
||||
l2File.Close()
|
||||
|
||||
serverStarted <- stderr
|
||||
|
||||
close(serverStarted)
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user