Skip to content

Commit

Permalink
add close printer
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Aug 7, 2024
1 parent c108cf5 commit f2f5321
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,9 @@ func (t *Torrent) close(wg *sync.WaitGroup) (err error) {
err = errors.New("already closed")
return
}

fmt.Println("CLS", t.name(true))

for _, f := range t.onClose {
f()
}
Expand Down Expand Up @@ -1098,7 +1101,7 @@ func (t *Torrent) close(wg *sync.WaitGroup) (err error) {
if t.storage != nil {
closed := make(chan struct{})
defer func() { closed <- struct{}{} }()

fmt.Println("ST CLS", t.name(true))
wg.Add(1)
go func() {
defer wg.Done()
Expand All @@ -1107,9 +1110,9 @@ func (t *Torrent) close(wg *sync.WaitGroup) (err error) {
defer t.storageLock.Unlock()
if f := t.storage.Close; f != nil {
fmt.Println("CLS", t.name(true))
err1 := f()
if err1 != nil {
t.logger.WithDefaultLevel(log.Warning).Printf("error closing storage: %v", err1)
if err := f(); err != nil {
fmt.Println("ERR", t.name(true))
t.logger.WithDefaultLevel(log.Warning).Printf("error closing storage: %v", err)
}
}
}()
Expand Down

0 comments on commit f2f5321

Please sign in to comment.