Check disk before even trying to run the download
This commit is contained in:
@@ -48,6 +48,15 @@ func (fs *Filesystem) SetDiskLimit(i int64) {
|
||||
fs.mu.Unlock()
|
||||
}
|
||||
|
||||
// The same concept as HasSpaceAvailable however this will return an error if there is
|
||||
// no space, rather than a boolean value.
|
||||
func (fs *Filesystem) HasSpaceErr(allowStaleValue bool) error {
|
||||
if !fs.HasSpaceAvailable(allowStaleValue) {
|
||||
return &Error{code: ErrCodeDiskSpace}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Determines if the directory a file is trying to be added to has enough space available
|
||||
// for the file to be written to.
|
||||
//
|
||||
|
||||
@@ -67,10 +67,6 @@ func IsErrorCode(err error, code ErrorCode) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func NewDiskSpaceError() *Error {
|
||||
return &Error{code: ErrCodeDiskSpace}
|
||||
}
|
||||
|
||||
// Returns a new BadPathResolution error.
|
||||
func NewBadPathResolution(path string, resolved string) *Error {
|
||||
return &Error{code: ErrCodePathResolution, path: path, resolved: resolved}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"emperror.dev/errors"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/environment"
|
||||
"github.com/pterodactyl/wings/server/filesystem"
|
||||
"golang.org/x/sync/semaphore"
|
||||
"os"
|
||||
"time"
|
||||
@@ -168,8 +167,8 @@ func (s *Server) onBeforeStart() error {
|
||||
s.Filesystem().HasSpaceAvailable(true)
|
||||
} else {
|
||||
s.PublishConsoleOutputFromDaemon("Checking server disk space usage, this could take a few seconds...")
|
||||
if !s.Filesystem().HasSpaceAvailable(false) {
|
||||
return filesystem.NewDiskSpaceError()
|
||||
if err := s.Filesystem().HasSpaceErr(false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user