mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-03 12:28:28 +00:00
wip
This commit is contained in:
parent
deb2f42a35
commit
7fc435481d
@ -157,8 +157,13 @@ func inWritableDir(fn func(string) error, targetFs fs.Filesystem, path string, i
|
||||
// by a large amount at the end of the operation.
|
||||
func addTimeUntilCancelled(ctx context.Context, counter prometheus.Counter) {
|
||||
t0 := time.Now()
|
||||
defer func() {
|
||||
counter.Add(time.Since(t0).Seconds())
|
||||
}()
|
||||
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
@ -166,7 +171,7 @@ func addTimeUntilCancelled(ctx context.Context, counter prometheus.Counter) {
|
||||
counter.Add(t1.Sub(t0).Seconds())
|
||||
t0 = t1
|
||||
case <-ctx.Done():
|
||||
counter.Add(time.Since(t0).Seconds())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user