mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-19 05:02:34 +00:00
ipn: have NewFileStore try to create directories as needed
This commit is contained in:
parent
b3d9eab1fe
commit
68ff31a0ba
@ -9,6 +9,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"tailscale.com/atomicfile"
|
"tailscale.com/atomicfile"
|
||||||
@ -73,6 +74,7 @@ func NewFileStore(path string) (*FileStore, error) {
|
|||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
// Write out an initial file, to verify that we can write
|
// Write out an initial file, to verify that we can write
|
||||||
// to the path.
|
// to the path.
|
||||||
|
os.MkdirAll(filepath.Dir(path), 0755) // best effort
|
||||||
if err = atomicfile.WriteFile(path, []byte("{}"), 0600); err != nil {
|
if err = atomicfile.WriteFile(path, []byte("{}"), 0600); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user