MCPcopy
hub / github.com/syncthing/syncthing / Write

Method Write

cmd/syncthing/monitor.go:357–374  ·  view source on GitHub ↗
(bs []byte)

Source from the content-addressed store, hash-verified

355}
356
357func (r *rotatedFile) Write(bs []byte) (int, error) {
358 // Check if we're about to exceed the max size, and if so close this
359 // file so we'll start on a new one.
360 if r.currentSize+int64(len(bs)) > r.maxSize {
361 r.currentFile.Close()
362 r.currentSize = 0
363 r.rotate()
364 f, err := r.create(r.name)
365 if err != nil {
366 return 0, err
367 }
368 r.currentFile = f
369 }
370
371 n, err := r.currentFile.Write(bs)
372 r.currentSize += int64(n)
373 return n, err
374}
375
376func (r *rotatedFile) rotate() {
377 // The files are named "name", "name.0", "name.1", ...

Callers 15

serveGetMethod · 0.45
ServeMethod · 0.45
compressAndWriteFunction · 0.45
mainFunction · 0.45
getStatusFunction · 0.45
proxyMethod · 0.45
connectToStdioFunction · 0.45
genFunction · 0.45
signFunction · 0.45
TestRotatedFileFunction · 0.45
TestAutoClosedFileFunction · 0.45
copyStderrFunction · 0.45

Calls 3

rotateMethod · 0.95
createMethod · 0.80
CloseMethod · 0.65

Tested by 2

TestRotatedFileFunction · 0.36
TestAutoClosedFileFunction · 0.36