diff --git a/cmd/media_repo/reloads.go b/cmd/media_repo/reloads.go index e17a64d2b245418e184f2e444324b6d03e690140..f1e8eda17ee9f39925ef1f9960951cc95f5e8b35 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 ba618cb0d2600201317fd33dd03de3254b47c548..45f6a15cbf1fe65af282a1a867db3328b0e326e7 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 d2f1ed9935061a562525639c1c0c7fc87db827bd..6d91c813f66140efa9c63ce4e71ad5123fb4f29d 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 }