Skip to content

Commit 041b4fb

Browse files
committed
fix: bypass writing stage when too few working nodes
1 parent 73dbe6f commit 041b4fb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/v2rayprobe/litespeedtest/web/profile.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const (
5151
)
5252

5353
const (
54-
remarkPrefix = "SubFinder"
54+
remarkPrefix = "SubFinder"
55+
MinCountToWrite = 10
5556
)
5657

5758
// support proxy
@@ -542,10 +543,12 @@ func (p *ProfileTest) testAll(ctx context.Context) (render.Nodes, error) {
542543
nodes.Sort(p.Options.SortMethod)
543544
nodes.ChangeRemarks(remarkPrefix)
544545
// save json
545-
if p.Options.OutputMode == JSON_OUTPUT {
546-
p.saveJSON(nodes, traffic, duration, successCount, linksCount)
547-
} else if p.Options.OutputMode == TEXT_OUTPUT {
548-
p.saveText(nodes)
546+
if len(nodes) >= MinCountToWrite {
547+
if p.Options.OutputMode == JSON_OUTPUT {
548+
p.saveJSON(nodes, traffic, duration, successCount, linksCount)
549+
} else if p.Options.OutputMode == TEXT_OUTPUT {
550+
p.saveText(nodes)
551+
}
549552
}
550553
return nodes, nil
551554
}
@@ -630,7 +633,6 @@ func (p *ProfileTest) testAllBatch(ctx context.Context, workerPoolSize int) (ren
630633
return nodes, nil
631634
}
632635

633-
634636
func (p *ProfileTest) saveJSON(nodes render.Nodes, traffic int64, duration string, successCount int, linksCount int) error {
635637
jsonOutput := JSONOutput{
636638
Nodes: nodes,

0 commit comments

Comments
 (0)