Fix chmod endpoint
This commit is contained in:
		
							parent
							
								
									f62f714863
								
							
						
					
					
						commit
						c6e2889075
					
				| 
						 | 
					@ -2,6 +2,7 @@ package router
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
						"github.com/apex/log"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
						"github.com/gin-gonic/gin"
 | 
				
			||||||
	"github.com/pkg/errors"
 | 
						"github.com/pkg/errors"
 | 
				
			||||||
	"github.com/pterodactyl/wings/router/tokens"
 | 
						"github.com/pterodactyl/wings/router/tokens"
 | 
				
			||||||
| 
						 | 
					@ -367,7 +368,7 @@ func postServerDecompressFiles(c *gin.Context) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type chmodFile struct {
 | 
					type chmodFile struct {
 | 
				
			||||||
	File string `json:"file"`
 | 
						File string `json:"file"`
 | 
				
			||||||
	Mode os.FileMode `json:"mode"`
 | 
						Mode string `json:"mode"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func postServerChmodFile(c *gin.Context) {
 | 
					func postServerChmodFile(c *gin.Context) {
 | 
				
			||||||
| 
						 | 
					@ -379,6 +380,7 @@ func postServerChmodFile(c *gin.Context) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := c.BindJSON(&data); err != nil {
 | 
						if err := c.BindJSON(&data); err != nil {
 | 
				
			||||||
 | 
							log.Debug(err.Error())
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -398,7 +400,12 @@ func postServerChmodFile(c *gin.Context) {
 | 
				
			||||||
			case <-ctx.Done():
 | 
								case <-ctx.Done():
 | 
				
			||||||
				return ctx.Err()
 | 
									return ctx.Err()
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				if err := s.Filesystem().Chmod(path.Join(data.Root, p.File), p.Mode); err != nil {
 | 
									mode, err := strconv.ParseUint(p.Mode, 10, 32)
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if err := s.Filesystem().Chmod(path.Join(data.Root, p.File), os.FileMode(uint32(mode))); err != nil {
 | 
				
			||||||
					// 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) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user