diff options
author | zeripath <art27@cantab.net> | 2022-08-28 10:43:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-28 10:43:25 +0100 |
commit | bb0ff77e461ae080b1722701aea74010ff71e0ae (patch) | |
tree | d9550dc2f4342ca5babc4bf9191fa51aacdb922e /integrations | |
parent | c21d6511a8e0084644a53a3192f45443456b9a32 (diff) | |
download | gitea-bb0ff77e461ae080b1722701aea74010ff71e0ae.tar.gz gitea-bb0ff77e461ae080b1722701aea74010ff71e0ae.zip |
Share HTML template renderers and create a watcher framework (#20218)
The recovery, API, Web and package frameworks all create their own HTML
Renderers. This increases the memory requirements of Gitea
unnecessarily with duplicate templates being kept in memory.
Further the reloading framework in dev mode for these involves locking
and recompiling all of the templates on each load. This will potentially
hide concurrency issues and it is inefficient.
This PR stores the templates renderer in the context and stores this
context in the NormalRoutes, it then creates a fsnotify.Watcher
framework to watch files.
The watching framework is then extended to the mailer templates which
were previously not being reloaded in dev.
Then the locales are simplified to a similar structure.
Fix #20210
Fix #20211
Fix #20217
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/api_activitypub_person_test.go | 12 | ||||
-rw-r--r-- | integrations/api_nodeinfo_test.go | 5 | ||||
-rw-r--r-- | integrations/create_no_session_test.go | 5 | ||||
-rw-r--r-- | integrations/integration_test.go | 2 |
4 files changed, 13 insertions, 11 deletions
diff --git a/integrations/api_activitypub_person_test.go b/integrations/api_activitypub_person_test.go index e19da40864..c0548df0bc 100644 --- a/integrations/api_activitypub_person_test.go +++ b/integrations/api_activitypub_person_test.go @@ -23,10 +23,10 @@ import ( func TestActivityPubPerson(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) }() onGiteaRun(t, func(*testing.T, *url.URL) { @@ -60,10 +60,10 @@ func TestActivityPubPerson(t *testing.T) { func TestActivityPubMissingPerson(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) }() onGiteaRun(t, func(*testing.T, *url.URL) { @@ -75,10 +75,10 @@ func TestActivityPubMissingPerson(t *testing.T) { func TestActivityPubPersonInbox(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) }() srv := httptest.NewServer(c) diff --git a/integrations/api_nodeinfo_test.go b/integrations/api_nodeinfo_test.go index cf9ff4da1b..bbb7912078 100644 --- a/integrations/api_nodeinfo_test.go +++ b/integrations/api_nodeinfo_test.go @@ -5,6 +5,7 @@ package integrations import ( + "context" "net/http" "net/url" "testing" @@ -18,10 +19,10 @@ import ( func TestNodeinfo(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) }() onGiteaRun(t, func(*testing.T, *url.URL) { diff --git a/integrations/create_no_session_test.go b/integrations/create_no_session_test.go index 49234c1e95..017fe1d356 100644 --- a/integrations/create_no_session_test.go +++ b/integrations/create_no_session_test.go @@ -5,6 +5,7 @@ package integrations import ( + "context" "net/http" "net/http/httptest" "os" @@ -57,7 +58,7 @@ func TestSessionFileCreation(t *testing.T) { oldSessionConfig := setting.SessionConfig.ProviderConfig defer func() { setting.SessionConfig.ProviderConfig = oldSessionConfig - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) }() var config session.Options @@ -82,7 +83,7 @@ func TestSessionFileCreation(t *testing.T) { setting.SessionConfig.ProviderConfig = string(newConfigBytes) - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) t.Run("NoSessionOnViewIssue", func(t *testing.T) { defer PrintCurrentTest(t)() diff --git a/integrations/integration_test.go b/integrations/integration_test.go index 3c379f5c84..a506c6a825 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -89,7 +89,7 @@ func TestMain(m *testing.M) { defer cancel() initIntegrationTest() - c = routers.NormalRoutes() + c = routers.NormalRoutes(context.TODO()) // integration test settings... if setting.Cfg != nil { |