Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 20:45 UTC
core: Always make AppDataDir for InstanceID (#5976)
Aziz Rmadi committed
Dec 13, 2023 at 08:39 UTC
cbbd1df904231de58ab6c29e681050c4709169be
1 file changed
+6
-1
caddy.go
+6
-1
@@ -825,13 +825,18 @@ func ParseDuration(s string) (time.Duration, error) {
825
// regardless of storage configuration, since each instance is intended to
826
// have its own unique ID.
827
func InstanceID() (uuid.UUID, error) {
828
- uuidFilePath := filepath.Join(AppDataDir(), "instance.uuid")
828
+ appDataDir := AppDataDir()
829
+ uuidFilePath := filepath.Join(appDataDir, "instance.uuid")
830
uuidFileBytes, err := os.ReadFile(uuidFilePath)
831
if os.IsNotExist(err) {
832
uuid, err := uuid.NewRandom()
833
if err != nil {
834
return uuid, err
835
}
836
+ err = os.MkdirAll(appDataDir, 0o600)
837
+ if err != nil {
838
+ return uuid, err
839
+ }
840
err = os.WriteFile(uuidFilePath, []byte(uuid.String()), 0o600)
841
return uuid, err
842
} else if err != nil {