Compare commits

...

4 Commits

Author SHA1 Message Date
Pterodactyl CI
565c11b1a0 bump version for release 2024-03-13 21:23:34 +00:00
Matthew Penner
8f129931d5 Update CHANGELOG.md
Signed-off-by: Matthew Penner <me@matthewp.io>
2024-03-13 15:19:24 -06:00
Matthew Penner
2931430eb8 server(filesystem): fix archive skipping directories
Fixes https://github.com/pterodactyl/panel/issues/5027

Signed-off-by: Matthew Penner <me@matthewp.io>
2024-03-13 15:09:24 -06:00
Matthew Penner
99b9924a4a router(server): fix panic on server deletion
Fixes https://github.com/pterodactyl/panel/issues/5028

Signed-off-by: Matthew Penner <me@matthewp.io>
2024-03-13 14:46:17 -06:00
5 changed files with 29 additions and 21 deletions

View File

@@ -1,5 +1,10 @@
# Changelog
## v1.11.10
### Fixed
* Archives randomly ignoring files and directories ([#5027](https://github.com/pterodactyl/panel/issues/5027))
* Crash when deleting or transferring a server ([#5028](https://github.com/pterodactyl/panel/issues/5028))
## v1.11.9
### Changed
* Release binaries are now built with Go 1.21.8

View File

@@ -227,20 +227,19 @@ func deleteServer(c *gin.Context) {
//
// In addition, servers with large amounts of files can take some time to finish deleting,
// so we don't want to block the HTTP call while waiting on this.
go func(p string) {
_ = s.Filesystem().UnixFS().Close()
go func(s *server.Server) {
fs := s.Filesystem()
p := fs.Path()
_ = fs.UnixFS().Close()
if err := os.RemoveAll(p); err != nil {
log.WithFields(log.Fields{"path": p, "error": err}).Warn("failed to remove server files during deletion process")
}
}(s.Filesystem().Path())
}(s)
middleware.ExtractManager(c).Remove(func(server *server.Server) bool {
return server.ID() == s.ID()
})
// Deallocate the reference to this server.
s = nil
c.Status(http.StatusNoContent)
}

View File

@@ -66,10 +66,9 @@ type Archive struct {
// BaseDirectory .
BaseDirectory string
// Files specifies the files to archive, this takes priority over the Ignore option, if
// unspecified, all files in the BasePath will be archived unless Ignore is set.
//
// All items in Files must be absolute within BasePath.
// Files specifies the files to archive, this takes priority over the Ignore
// option, if unspecified, all files in the BaseDirectory will be archived
// unless Ignore is set.
Files []string
// Progress wraps the writer of the archive to pass through the progress tracker.
@@ -114,11 +113,16 @@ func (a *Archive) Stream(ctx context.Context, w io.Writer) error {
return errors.New("filesystem: archive.Filesystem is unset")
}
if filesLen := len(a.Files); filesLen > 0 {
files := make([]string, filesLen)
for i, f := range a.Files {
if !strings.HasPrefix(f, a.Filesystem.Path()) {
files[i] = f
continue
}
a.Files[i] = strings.TrimPrefix(strings.TrimPrefix(f, a.Filesystem.Path()), "/")
files[i] = strings.TrimPrefix(strings.TrimPrefix(f, a.Filesystem.Path()), "/")
}
a.Files = files
}
// Choose which compression level to use based on the compression_level configuration option
@@ -128,8 +132,6 @@ func (a *Archive) Stream(ctx context.Context, w io.Writer) error {
compressionLevel = pgzip.NoCompression
case "best_compression":
compressionLevel = pgzip.BestCompression
case "best_speed":
fallthrough
default:
compressionLevel = pgzip.BestSpeed
}
@@ -196,6 +198,9 @@ func (a *Archive) callback(opts ...walkFunc) walkFunc {
// a non-nil error we will exit immediately.
for _, opt := range opts {
if err := opt(dirfd, name, relative, d); err != nil {
if err == SkipThis {
return nil
}
return err
}
}
@@ -206,6 +211,8 @@ func (a *Archive) callback(opts ...walkFunc) walkFunc {
}
}
var SkipThis = errors.New("skip this")
// Pushes only files defined in the Files key to the final archive.
func (a *Archive) withFilesCallback() walkFunc {
return a.callback(func(_ int, _, relative string, _ ufs.DirEntry) error {
@@ -225,7 +232,7 @@ func (a *Archive) withFilesCallback() walkFunc {
return nil
}
return ufs.SkipDir
return SkipThis
})
}

View File

@@ -21,9 +21,6 @@ import (
"github.com/pterodactyl/wings/internal/ufs"
)
// TODO: detect and enable
var useOpenat2 = true
type Filesystem struct {
unixFS *ufs.Quota

View File

@@ -1,3 +1,3 @@
package system
var Version = "develop"
var Version = "1.11.10"