Skip to content

Commit

Permalink
Include error in log output if one occurs during move
Browse files Browse the repository at this point in the history
  • Loading branch information
DaneEveritt committed May 21, 2022
1 parent 5df1acd commit f390784
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* 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 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
* 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 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 `[email protected]`).

## v1.6.1
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions router/router_server_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func putServerRenameFiles(c *gin.Context) {
// Return nil if the error is an is not exists.
// NOTE: os.IsNotExist() does not work if the error is wrapped.
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 err
Expand Down
11 changes: 7 additions & 4 deletions server/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ func (fs *Filesystem) CreateDirectory(name string, p string) error {
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 {
cleanedFrom, err := fs.SafePath(from)
if err != nil {
return err
return errors.WithStack(err)
}

cleanedTo, err := fs.SafePath(to)
if err != nil {
return err
return errors.WithStack(err)
}

// If the target file or directory already exists the rename function will fail, so just
Expand All @@ -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
Expand Down

0 comments on commit f390784

Please sign in to comment.