MCPcopy
hub / github.com/kopia/kopia / Write

Method Write

repo/object/object_writer.go:113–139  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

111}
112
113func (w *objectWriter) Write(data []byte) (n int, err error) {
114 w.mu.Lock()
115 defer w.mu.Unlock()
116
117 dataLen := len(data)
118 w.totalLength += int64(dataLen)
119
120 for len(data) > 0 {
121 n := w.splitter.NextSplitPoint(data)
122 if n < 0 {
123 // no split points in the buffer
124 w.buffer.Append(data)
125 break
126 }
127
128 // found a split point after `n` bytes, write first n bytes then flush and repeat with the remainder.
129 w.buffer.Append(data[0:n])
130
131 if err := w.flushBufferLocked(); err != nil {
132 return 0, err
133 }
134
135 data = data[n:]
136 }
137
138 return dataLen, nil
139}
140
141// +checklocks:w.mu
142func (w *objectWriter) flushBufferLocked() error {

Callers 15

GetContentMethod · 0.45
TestWritersMethod · 0.45
TestHMACMethod · 0.45
writeObjectFunction · 0.45
TestFormatsFunction · 0.45
BenchmarkWriterDedup1MFunction · 0.45
BenchmarkWriterNoDedup1MFunction · 0.45
ResetMethod · 0.45

Calls 5

flushBufferLockedMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
NextSplitPointMethod · 0.65
AppendMethod · 0.45

Tested by 15

TestWritersMethod · 0.36
TestHMACMethod · 0.36
writeObjectFunction · 0.36
TestFormatsFunction · 0.36
BenchmarkWriterDedup1MFunction · 0.36
BenchmarkWriterNoDedup1MFunction · 0.36
mustPutDummySessionBlobFunction · 0.36
TestWritersFunction · 0.36