From f390784973fe5124fff216c5daf8bfb916fb829e Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sat, 21 May 2022 17:01:12 -0400 Subject: [PATCH] Include error in log output if one occurs during move --- CHANGELOG.md | 2 ++ router/router_server_files.go | 4 ++++ server/filesystem/filesystem.go | 11 +++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ec6cc..37368db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `Panel@1.8.0`). ## v1.6.1 ### Fixed diff --git a/router/router_server_files.go b/router/router_server_files.go index 999b0c0..6531931 100644 --- a/router/router_server_files.go +++ b/router/router_server_files.go @@ -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 diff --git a/server/filesystem/filesystem.go b/server/filesystem/filesystem.go index f4f66b9..cb70b44 100644 --- a/server/filesystem/filesystem.go +++ b/server/filesystem/filesystem.go @@ -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 @@ -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