Code cleanup and avoid server race

This commit is contained in:
Dane Everitt 2020-07-19 17:50:39 -07:00
parent e28c05ae56
commit 5079c67aee
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 3 additions and 6 deletions

View File

@ -41,13 +41,12 @@ func IsPathResolutionError(err error) bool {
type Filesystem struct { type Filesystem struct {
Server *Server Server *Server
Configuration *config.SystemConfiguration
cacheDiskMu sync.Mutex cacheDiskMu sync.Mutex
} }
// Returns the root path that contains all of a server's data. // Returns the root path that contains all of a server's data.
func (fs *Filesystem) Path() string { func (fs *Filesystem) Path() string {
return filepath.Join(fs.Configuration.Data, fs.Server.Uuid) return filepath.Join(config.Get().System.Data, fs.Server.Id())
} }
// Normalizes a directory being passed in to ensure the user is not able to escape // Normalizes a directory being passed in to ensure the user is not able to escape
@ -475,7 +474,7 @@ func (fs *Filesystem) Chown(path string) error {
if s, err := os.Stat(cleaned); err != nil { if s, err := os.Stat(cleaned); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} else if !s.IsDir() { } else if !s.IsDir() {
return os.Chown(cleaned, fs.Configuration.User.Uid, fs.Configuration.User.Gid) return os.Chown(cleaned, config.Get().System.User.Uid, config.Get().System.User.Gid)
} }
return fs.chownDirectory(cleaned) return fs.chownDirectory(cleaned)
@ -521,7 +520,7 @@ func (fs *Filesystem) chownDirectory(path string) error {
fs.chownDirectory(p) fs.chownDirectory(p)
}(p) }(p)
} else { } else {
os.Chown(p, fs.Configuration.User.Uid, fs.Configuration.User.Gid) os.Chown(p, config.Get().System.User.Uid, config.Get().System.User.Gid)
} }
} }

View File

@ -6,7 +6,6 @@ import (
"github.com/patrickmn/go-cache" "github.com/patrickmn/go-cache"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/pterodactyl/wings/api" "github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/config"
"github.com/remeh/sizedwaitgroup" "github.com/remeh/sizedwaitgroup"
"time" "time"
) )
@ -109,7 +108,6 @@ func FromConfiguration(data *api.ServerConfigurationResponse) (*Server, error) {
Server: s, Server: s,
} }
s.Filesystem = Filesystem{ s.Filesystem = Filesystem{
Configuration: &config.Get().System,
Server: s, Server: s,
} }