Include error in log output if one occurs during move

This commit is contained in:
DaneEveritt 2022-05-21 17:01:12 -04:00
parent 5df1acd10e
commit f390784973
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 13 additions and 4 deletions

View File

@ -5,12 +5,14 @@
* Fixes file upload size not being properly enforced. * Fixes file upload size not being properly enforced.
* Fixes a bug that prevented listing a directory when it contained a named pipe. Also added a check to prevent attempting to read a named pipe directly. * Fixes a bug that prevented listing a directory when it contained a named pipe. Also added a check to prevent attempting to read a named pipe directly.
* Fixes a bug with the archiver logic that would include folders that had the same name prefix. (for example, requesting only `map` would also include `map2` and `map3`) * Fixes a bug with the archiver logic that would include folders that had the same name prefix. (for example, requesting only `map` would also include `map2` and `map3`)
* Requests to the Panel that return a client error (4xx response code) no longer trigger an exponential backoff, they immediately stop the request.
### Changed ### Changed
* CPU limit fields are only set on the Docker container if they have been specified for the server — otherwise they are left empty. * CPU limit fields are only set on the Docker container if they have been specified for the server — otherwise they are left empty.
### Added ### Added
* Added the ability to define the location of the temporary folder used by Wings — defaults to `/tmp/pterodactyl`. * Added the ability to define the location of the temporary folder used by Wings — defaults to `/tmp/pterodactyl`.
* Adds the ability to authenticate for SFTP using public keys (requires `Panel@1.8.0`).
## v1.6.1 ## v1.6.1
### Fixed ### Fixed

View File

@ -131,6 +131,10 @@ func putServerRenameFiles(c *gin.Context) {
// Return nil if the error is an is not exists. // Return nil if the error is an is not exists.
// NOTE: os.IsNotExist() does not work if the error is wrapped. // NOTE: os.IsNotExist() does not work if the error is wrapped.
if errors.Is(err, os.ErrNotExist) { if errors.Is(err, os.ErrNotExist) {
s.Log().WithField("error", err).
WithField("from_path", pf).
WithField("to_path", pt).
Warn("failed to rename: source or target does not exist")
return nil return nil
} }
return err return err

View File

@ -171,16 +171,16 @@ func (fs *Filesystem) CreateDirectory(name string, p string) error {
return os.MkdirAll(cleaned, 0o755) return os.MkdirAll(cleaned, 0o755)
} }
// Moves (or renames) a file or directory. // Rename moves (or renames) a file or directory.
func (fs *Filesystem) Rename(from string, to string) error { func (fs *Filesystem) Rename(from string, to string) error {
cleanedFrom, err := fs.SafePath(from) cleanedFrom, err := fs.SafePath(from)
if err != nil { if err != nil {
return err return errors.WithStack(err)
} }
cleanedTo, err := fs.SafePath(to) cleanedTo, err := fs.SafePath(to)
if err != nil { if err != nil {
return err return errors.WithStack(err)
} }
// If the target file or directory already exists the rename function will fail, so just // If the target file or directory already exists the rename function will fail, so just
@ -202,7 +202,10 @@ func (fs *Filesystem) Rename(from string, to string) error {
} }
} }
return os.Rename(cleanedFrom, cleanedTo) if err := os.Rename(cleanedFrom, cleanedTo); err != nil {
return errors.WithStack(err)
}
return nil
} }
// Recursively iterates over a file or directory and sets the permissions on all of the // Recursively iterates over a file or directory and sets the permissions on all of the