all repos — website @ 6e092d6456f870df0ae90f400e6848d748a93c4c

My website

only create a tempdir in development mode
Alan Pearce alan@alanpearce.eu
Sat, 29 Jun 2024 10:13:44 +0200
commit

6e092d6456f870df0ae90f400e6848d748a93c4c

parent

8606328379e7021a2e4bf0d56c0602fa595fa72e

1 files changed, 7 insertions(+), 5 deletions(-)

jump to
M cmd/server/main.gocmd/server/main.go
@@ -25,12 +25,14 @@ panic("parsing runtime configuration" + err.Error()) 	}
 	log.Configure(!runtimeConfig.Development)
 
-	tmpdir, err := os.MkdirTemp("", "website")
-	if err != nil {
-		log.Fatal("could not create temporary directory", "error", err)
+	if runtimeConfig.Development {
+		tmpdir, err := os.MkdirTemp("", "website")
+		if err != nil {
+			log.Fatal("could not create temporary directory", "error", err)
+		}
+		defer os.RemoveAll(tmpdir)
+		runtimeConfig.Root = tmpdir
 	}
-	defer os.RemoveAll(tmpdir)
-	runtimeConfig.Root = tmpdir
 
 	sv, err := server.New(&runtimeConfig)
 	if err != nil {