refactor code for context fallthrough

This commit is contained in:
Lawrence, Rendall
2022-11-01 17:02:24 +03:00
parent d6de38bdbd
commit d8d6f2cf4b
22 changed files with 312 additions and 493 deletions

View File

@@ -5,6 +5,7 @@ package torrentapproval
import (
"context"
"fmt"
"io"
"github.com/sot-tech/mochi/bittorrent"
"github.com/sot-tech/mochi/middleware"
@@ -17,7 +18,6 @@ import (
// import static list to enable appropriate support
_ "github.com/sot-tech/mochi/middleware/torrentapproval/container/list"
"github.com/sot-tech/mochi/pkg/stop"
"github.com/sot-tech/mochi/storage"
)
@@ -86,9 +86,9 @@ func (h *hook) HandleScrape(ctx context.Context, _ *bittorrent.ScrapeRequest, _
return ctx, nil
}
func (h *hook) Stop() stop.Result {
if st, isOk := h.hashContainer.(stop.Stopper); isOk {
return st.Stop()
func (h *hook) Close() (err error) {
if cl, isOk := h.hashContainer.(io.Closer); isOk {
err = cl.Close()
}
return stop.AlreadyStopped
return err
}