telemetry: create ~/.config/dagger directory if it doesn't exit
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
c17ce97381
commit
3d06252858
@ -4,8 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -147,6 +149,14 @@ func getDeviceID() (string, error) {
|
|||||||
}
|
}
|
||||||
id, err := os.ReadFile(idFile)
|
id, err := os.ReadFile(idFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(filepath.Dir(idFile), 0755); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
id = []byte(uuid.New().String())
|
id = []byte(uuid.New().String())
|
||||||
if err := os.WriteFile(idFile, id, 0600); err != nil {
|
if err := os.WriteFile(idFile, id, 0600); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Reference in New Issue
Block a user