Make Golang correctly delete temp files during uploading (#36128) (#36129)

Fix #36127

Partially backport #36128
And by the way partially backport  #36017
This commit is contained in:
wxiaoguang
2025-12-12 03:10:59 +08:00
committed by GitHub
parent e98d9bb93e
commit 3d66e75a47
7 changed files with 55 additions and 13 deletions

View File

@@ -46,11 +46,15 @@ func RouterMockPoint(pointName string) func(next http.Handler) http.Handler {
//
// Then the mock function will be executed as a middleware at the mock point.
// It only takes effect in testing mode (setting.IsInTesting == true).
func RouteMock(pointName string, h any) {
func RouteMock(pointName string, h any) func() {
if _, ok := routeMockPoints[pointName]; !ok {
panic("route mock point not found: " + pointName)
}
old := routeMockPoints[pointName]
routeMockPoints[pointName] = toHandlerProvider(h)
return func() {
routeMockPoints[pointName] = old
}
}
// RouteMockReset resets all mock points (no mock anymore)