mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Fixed --output-file-size-limit
This commit is contained in:
+5
-3
@@ -66,12 +66,12 @@ type FileOutput struct {
|
|||||||
currentName string
|
currentName string
|
||||||
file *os.File
|
file *os.File
|
||||||
QueueLength int
|
QueueLength int
|
||||||
chunkSize int
|
|
||||||
writer io.Writer
|
writer io.Writer
|
||||||
requestPerFile bool
|
requestPerFile bool
|
||||||
currentID []byte
|
currentID []byte
|
||||||
payloadType []byte
|
payloadType []byte
|
||||||
closed bool
|
closed bool
|
||||||
|
currentFileSize int
|
||||||
totalFileSize size.Size
|
totalFileSize size.Size
|
||||||
|
|
||||||
config *FileOutputConfig
|
config *FileOutputConfig
|
||||||
@@ -174,7 +174,7 @@ func (o *FileOutput) filename() string {
|
|||||||
|
|
||||||
if o.currentName == "" ||
|
if o.currentName == "" ||
|
||||||
((o.config.QueueLimit > 0 && o.QueueLength >= o.config.QueueLimit) ||
|
((o.config.QueueLimit > 0 && o.QueueLength >= o.config.QueueLimit) ||
|
||||||
(o.config.SizeLimit > 0 && o.chunkSize >= int(o.config.SizeLimit))) {
|
(o.config.SizeLimit > 0 && o.currentFileSize >= int(o.config.SizeLimit))) {
|
||||||
nextChunk = true
|
nextChunk = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +195,7 @@ func (o *FileOutput) filename() string {
|
|||||||
|
|
||||||
if nextChunk {
|
if nextChunk {
|
||||||
fileIndex++
|
fileIndex++
|
||||||
|
o.currentFileSize = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,6 +254,7 @@ func (o *FileOutput) PluginWrite(msg *Message) (n int, err error) {
|
|||||||
n += nn
|
n += nn
|
||||||
|
|
||||||
o.totalFileSize += size.Size(n)
|
o.totalFileSize += size.Size(n)
|
||||||
|
o.currentFileSize += n
|
||||||
o.QueueLength++
|
o.QueueLength++
|
||||||
|
|
||||||
if Settings.OutputFileConfig.OutputFileMaxSize > 0 && o.totalFileSize >= Settings.OutputFileConfig.OutputFileMaxSize {
|
if Settings.OutputFileConfig.OutputFileMaxSize > 0 && o.totalFileSize >= Settings.OutputFileConfig.OutputFileMaxSize {
|
||||||
@@ -281,7 +283,7 @@ func (o *FileOutput) flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if stat, err := o.file.Stat(); err == nil {
|
if stat, err := o.file.Stat(); err == nil {
|
||||||
o.chunkSize = int(stat.Size())
|
o.currentFileSize = int(stat.Size())
|
||||||
} else {
|
} else {
|
||||||
Debug(0, "[OUTPUT-HTTP] error accessing file size", err)
|
Debug(0, "[OUTPUT-HTTP] error accessing file size", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user