From 65308fa7b33f2a2646ea20ec061d6952b06b2f1c Mon Sep 17 00:00:00 2001
From: Travis Ralston <travpc@gmail.com>
Date: Mon, 17 Jul 2023 00:02:04 -0600
Subject: [PATCH] Small misc cleanup

---
 cmd/media_repo/reloads.go |  3 ---
 templating/templates.go   |  4 ++--
 util/random.go            | 12 ++----------
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/cmd/media_repo/reloads.go b/cmd/media_repo/reloads.go
index e17a64d2..f1e8eda1 100644
--- a/cmd/media_repo/reloads.go
+++ b/cmd/media_repo/reloads.go
@@ -7,7 +7,6 @@ import (
 	"github.com/turt2live/matrix-media-repo/common/runtime"
 	"github.com/turt2live/matrix-media-repo/database"
 	"github.com/turt2live/matrix-media-repo/errcache"
-	"github.com/turt2live/matrix-media-repo/internal_cache"
 	"github.com/turt2live/matrix-media-repo/metrics"
 	"github.com/turt2live/matrix-media-repo/plugins"
 	"github.com/turt2live/matrix-media-repo/pool"
@@ -134,10 +133,8 @@ func reloadCacheOnChan(reloadChan chan bool) {
 			shouldReload := <-reloadChan
 			if shouldReload {
 				redislib.Reconnect()
-				internal_cache.ReplaceInstance()
 			} else {
 				redislib.Stop()
-				internal_cache.Get().Stop()
 			}
 		}
 	}()
diff --git a/templating/templates.go b/templating/templates.go
index ba618cb0..45f6a15c 100644
--- a/templating/templates.go
+++ b/templating/templates.go
@@ -16,7 +16,7 @@ type templates struct {
 var instance *templates
 var singletonLock = &sync.Once{}
 
-func GetInstance() *templates {
+func getInstance() *templates {
 	if instance == nil {
 		singletonLock.Do(func() {
 			instance = &templates{
@@ -28,7 +28,7 @@ func GetInstance() *templates {
 }
 
 func GetTemplate(name string) (*template.Template, error) {
-	i := GetInstance()
+	i := getInstance()
 	if v, ok := i.cached[name]; ok {
 		return v, nil
 	}
diff --git a/util/random.go b/util/random.go
index d2f1ed99..6d91c813 100644
--- a/util/random.go
+++ b/util/random.go
@@ -6,17 +6,9 @@ import (
 	"encoding/hex"
 )
 
-func GenerateRandomBytes(n int) ([]byte, error) {
-	b := make([]byte, n)
-	_, err := rand.Read(b)
-	if err != nil {
-		return nil, err
-	}
-	return b, nil
-}
-
 func GenerateRandomString(nBytes int) (string, error) {
-	b, err := GenerateRandomBytes(nBytes)
+	b := make([]byte, nBytes)
+	_, err := rand.Read(b)
 	if err != nil {
 		return "", err
 	}
-- 
GitLab