diff --git a/go.mod b/go.mod index 7a674117..232e87a9 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/sagernet/gvisor v0.0.0-20230930141345-5fef6f2e17ab github.com/sagernet/quic-go v0.0.0-20231008035953-32727fef9460 github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 - github.com/sagernet/sing v0.2.16-0.20231028125948-afcc9cb766c2 + github.com/sagernet/sing v0.2.16-0.20231105072849-64e91d772616 github.com/sagernet/sing-dns v0.1.10 github.com/sagernet/sing-mux v0.1.4-0.20231105044304-ae2745a33479 github.com/sagernet/sing-quic v0.1.3-0.20231026034240-fa3d997246b6 diff --git a/go.sum b/go.sum index b10789e0..d4a18984 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byL github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU= github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY= github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= -github.com/sagernet/sing v0.2.16-0.20231028125948-afcc9cb766c2 h1:PW18IgRodvppd09d4mewYM3Hedu3PtFERN8yOqkTVk0= -github.com/sagernet/sing v0.2.16-0.20231028125948-afcc9cb766c2/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= +github.com/sagernet/sing v0.2.16-0.20231105072849-64e91d772616 h1:zIm6f7NQR8zhkAaoCIe8sL9Rp3HAkfoF+FGb4XEN3SY= +github.com/sagernet/sing v0.2.16-0.20231105072849-64e91d772616/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= github.com/sagernet/sing-dns v0.1.10 h1:iIU7nRBlUYj+fF2TaktGIvRiTFFrHwSMedLQsvlTZCI= github.com/sagernet/sing-dns v0.1.10/go.mod h1:vtUimtf7Nq9EdvD5WTpfCr69KL1M7bcgOVKiYBiAY/c= github.com/sagernet/sing-mux v0.1.4-0.20231105044304-ae2745a33479 h1:h6ANTA5wbP5BSqbjOT7s1OKLZgdsLqiXO564KQqY2i4= diff --git a/route/router_geo_resources.go b/route/router_geo_resources.go index b35515d1..523833dc 100644 --- a/route/router_geo_resources.go +++ b/route/router_geo_resources.go @@ -181,9 +181,11 @@ func (r *Router) downloadGeoIPDatabase(savePath string) error { if err != nil { return E.Cause(err, "open output file: ", downloadURL) } - defer saveFile.Close() - _, err = io.Copy(saveFile, response.Body) + saveFile.Close() + if err != nil { + filemanager.Remove(r.ctx, savePath) + } return err } @@ -234,9 +236,11 @@ func (r *Router) downloadGeositeDatabase(savePath string) error { if err != nil { return E.Cause(err, "open output file: ", downloadURL) } - defer saveFile.Close() - _, err = io.Copy(saveFile, response.Body) + saveFile.Close() + if err != nil { + filemanager.Remove(r.ctx, savePath) + } return err }