Ensure assets path exists before writing UUID file

This commit is contained in:
Matthew Holt 2018-08-26 09:13:59 -06:00
parent 93c5256318
commit 73273c5bf8
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -355,7 +355,12 @@ func initTelemetry() error {
newUUID := func() uuid.UUID {
id := uuid.New()
err := ioutil.WriteFile(uuidFilename, []byte(id.String()), 0600) // human-readable as a string
err := os.MkdirAll(caddy.AssetsPath(), 0700)
if err != nil {
log.Printf("[ERROR] Persisting instance UUID: %v", err)
return id
}
err = ioutil.WriteFile(uuidFilename, []byte(id.String()), 0600) // human-readable as a string
if err != nil {
log.Printf("[ERROR] Persisting instance UUID: %v", err)
}