Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2020-11-27 03:34:36 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-11-30 02:15:11 +0300
commitaeff2242f8b8fe51bb02539bf73b90bb6cf2ed1b (patch)
treed24bdc825d0fd644aaaf92e3f53799add2e77448
parentfd653cb8b358b010d08a10215827598d87be8911 (diff)
Use sync.Once instead of checking for nil
-rw-r--r--internal/serving/disk/zip/serving.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/serving/disk/zip/serving.go b/internal/serving/disk/zip/serving.go
index b552050c..61d186da 100644
--- a/internal/serving/disk/zip/serving.go
+++ b/internal/serving/disk/zip/serving.go
@@ -1,6 +1,8 @@
package zip
import (
+ "sync"
+
"gitlab.com/gitlab-org/gitlab-pages/internal/config"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk"
@@ -9,13 +11,14 @@ import (
)
var instance serving.Serving
+var once sync.Once
// Instance returns a serving instance that is capable of reading files
// from a zip archives opened from a URL, most likely stored in object storage
func Instance() serving.Serving {
- if instance == nil {
+ once.Do(func() {
instance = disk.New(vfs.Instrumented(zip.New(config.Default.Zip)))
- }
+ })
return instance
}