mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-31 00:04:44 +00:00
perf(appstore): reduce resource requests during synchronization
This commit is contained in:
@@ -4593,6 +4593,9 @@ const docTemplate = `{
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
},
|
||||
"302": {
|
||||
"description": "redirect to the official icon URL"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
@@ -5390,6 +5393,17 @@ const docTemplate = `{
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"in": "body",
|
||||
"name": "request",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.AppUpdateVersion"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
@@ -49266,6 +49280,23 @@ const docTemplate = `{
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"request.AppUpdateVersion": {
|
||||
"properties": {
|
||||
"appInstallID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"loadCompose": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"updateVersion": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"appInstallID"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"response.AppConfig": {
|
||||
"properties": {
|
||||
"advanced": {
|
||||
@@ -49298,6 +49329,9 @@ const docTemplate = `{
|
||||
"httpPort": {
|
||||
"type": "integer"
|
||||
},
|
||||
"isEdit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"memoryLimit": {
|
||||
"type": "number"
|
||||
},
|
||||
@@ -49576,6 +49610,9 @@ const docTemplate = `{
|
||||
"gpuSupport": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
||||
@@ -4542,6 +4542,9 @@
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
},
|
||||
"302": {
|
||||
"description": "redirect to the official icon URL"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
@@ -5339,6 +5342,17 @@
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"in": "body",
|
||||
"name": "request",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.AppUpdateVersion"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
@@ -47477,6 +47491,23 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"request.AppUpdateVersion": {
|
||||
"properties": {
|
||||
"appInstallID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"loadCompose": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"updateVersion": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"appInstallID"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"response.AppConfig": {
|
||||
"properties": {
|
||||
"advanced": {
|
||||
@@ -47503,6 +47534,9 @@
|
||||
"hostMode": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isEdit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"memoryLimit": {
|
||||
"type": "number"
|
||||
},
|
||||
@@ -47763,6 +47797,9 @@
|
||||
"gpuSupport": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type iconRedirectTransport func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (f iconRedirectTransport) RoundTrip(req *http.Request) (*http.Response, error) { return f(req) }
|
||||
|
||||
func TestLocalAppIconRedirectIsPassedToBrowser(t *testing.T) {
|
||||
const icon = "https://cdn.example/icon.png?signature=a%2Bb&v=42"
|
||||
calls := 0
|
||||
proxy := newLocalAgentProxy(iconRedirectTransport(func(req *http.Request) (*http.Response, error) {
|
||||
calls++
|
||||
if req.URL.Host != "unix" || req.URL.Path != "/api/v2/apps/icon/php" {
|
||||
t.Fatalf("proxy attempted to fetch a remote image: %s", req.URL)
|
||||
}
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusFound,
|
||||
Header: http.Header{"Location": {icon}, "Cache-Control": {"no-cache"}},
|
||||
Body: io.NopCloser(strings.NewReader("")),
|
||||
}, nil
|
||||
}))
|
||||
rw := httptest.NewRecorder()
|
||||
proxy.ServeHTTP(rw, httptest.NewRequest(http.MethodGet, "/api/v2/apps/icon/php", nil))
|
||||
if rw.Code != http.StatusFound || rw.Header().Get("Location") != icon || rw.Header().Get("Cache-Control") != "no-cache" || calls != 1 {
|
||||
t.Fatalf("local proxy did not preserve the redirect: status=%d headers=%v calls=%d", rw.Code, rw.Header(), calls)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user