Fix race condition on startup

This commit is contained in:
Matthew Penner 2020-08-05 21:13:01 -06:00
parent 642e6e6a96
commit ff7f92895c
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
build: build:
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -gcflags "all=-trimpath=/Users/dane/Sites/development/code" -o build/wings_linux_amd64 -v wings.go GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -gcflags "all=-trimpath=$(PWD)" -o build/wings_linux_amd64 -v wings.go
compress: compress:
upx --brute build/wings_* upx --brute build/wings_*

View File

@ -104,15 +104,15 @@ func FromConfiguration(data *api.ServerConfigurationResponse) (*Server, error) {
Server: s, Server: s,
} }
// If the server's data directory exists, force disk usage calculation.
if _, err := os.Stat(s.Filesystem.Path()); err == nil {
go s.Filesystem.HasSpaceAvailable()
}
// Forces the configuration to be synced with the panel. // Forces the configuration to be synced with the panel.
if err := s.SyncWithConfiguration(data); err != nil { if err := s.SyncWithConfiguration(data); err != nil {
return nil, err return nil, err
} }
// If the server's data directory exists, force disk usage calculation.
if _, err := os.Stat(s.Filesystem.Path()); err == nil {
go s.Filesystem.HasSpaceAvailable()
}
return s, nil return s, nil
} }