fix: symbol links are not displayed in config list #272

This commit is contained in:
0xJacky 2024-02-06 16:04:53 +08:00
parent 371472e67b
commit abe43c5c4d
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
3 changed files with 74 additions and 74 deletions

View file

@ -13,6 +13,7 @@ import (
func GetConfig(c *gin.Context) {
name := c.Param("name")
path := nginx.GetConfPath("/", name)
stat, err := os.Stat(path)

View file

@ -35,7 +35,7 @@ func GetConfigs(c *gin.Context) {
}
case mode&os.ModeSymlink != 0: // is a symbol
var targetPath string
targetPath, err = os.Readlink(nginx.GetConfPath(file.Name()))
targetPath, err = os.Readlink(nginx.GetConfPath(dir, file.Name()))
if err != nil {
logger.Error("Read Symlink Error", targetPath, err)
continue
@ -47,7 +47,7 @@ func GetConfigs(c *gin.Context) {
logger.Error("Stat Error", targetPath, err)
continue
}
// but target file is not a dir
// hide the file if it's target file is a directory
if targetInfo.IsDir() {
continue
}

View file

@ -30,7 +30,6 @@ func EditConfig(c *gin.Context) {
}
if content != "" && content != string(origContent) {
// model.CreateBackup(path)
err = os.WriteFile(path, []byte(content), 0644)
if err != nil {
api.ErrHandler(c, err)