mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-27 12:39:01 +08:00
fix: 主机文件打开软链接优化 (#6432)
This commit is contained in:
parent
2219b3f47b
commit
a0857f86b2
@ -72,6 +72,9 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
|
||||
|
||||
info, err := appFs.Stat(op.Path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, buserr.New(constant.ErrLinkPathNotFound)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -101,12 +104,25 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
|
||||
}
|
||||
|
||||
if file.IsSymlink {
|
||||
file.LinkPath = GetSymlink(op.Path)
|
||||
targetInfo, err := appFs.Stat(file.LinkPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
linkPath := GetSymlink(op.Path)
|
||||
if !filepath.IsAbs(linkPath) {
|
||||
dir := filepath.Dir(op.Path)
|
||||
var err error
|
||||
linkPath, err = filepath.Abs(filepath.Join(dir, linkPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
file.LinkPath = linkPath
|
||||
targetInfo, err := appFs.Stat(linkPath)
|
||||
if err != nil {
|
||||
file.IsDir = false
|
||||
file.Mode = "-"
|
||||
file.User = "-"
|
||||
file.Group = "-"
|
||||
} else {
|
||||
file.IsDir = targetInfo.IsDir()
|
||||
}
|
||||
file.IsDir = targetInfo.IsDir()
|
||||
file.Extension = filepath.Ext(file.LinkPath)
|
||||
}
|
||||
if op.Expand {
|
||||
@ -314,12 +330,25 @@ func (f *FileInfo) processFiles(files []FileSearchInfo, option FileOption) ([]*F
|
||||
file.FavoriteID = favorite.ID
|
||||
}
|
||||
if isSymlink {
|
||||
file.LinkPath = GetSymlink(fPath)
|
||||
targetInfo, err := file.Fs.Stat(file.LinkPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
linkPath := GetSymlink(fPath)
|
||||
if !filepath.IsAbs(linkPath) {
|
||||
dir := filepath.Dir(fPath)
|
||||
var err error
|
||||
linkPath, err = filepath.Abs(filepath.Join(dir, linkPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
file.LinkPath = linkPath
|
||||
targetInfo, err := file.Fs.Stat(linkPath)
|
||||
if err != nil {
|
||||
file.IsDir = false
|
||||
file.Mode = "-"
|
||||
file.User = "-"
|
||||
file.Group = "-"
|
||||
} else {
|
||||
file.IsDir = targetInfo.IsDir()
|
||||
}
|
||||
file.IsDir = targetInfo.IsDir()
|
||||
file.Extension = filepath.Ext(file.LinkPath)
|
||||
}
|
||||
if df.Size() > 0 {
|
||||
|
@ -1277,6 +1277,7 @@ const message = {
|
||||
noNameFolder: 'Untitled Folder',
|
||||
noNameFile: 'Untitled File',
|
||||
minimap: 'Code Mini Map',
|
||||
fileCanNotRead: 'File can not read',
|
||||
},
|
||||
ssh: {
|
||||
autoStart: 'Auto Start',
|
||||
|
@ -1211,6 +1211,7 @@ const message = {
|
||||
noNameFolder: '未命名資料夾',
|
||||
noNameFile: '未命名檔案',
|
||||
minimap: '縮略圖',
|
||||
fileCanNotRead: '此文件不支持預覽',
|
||||
},
|
||||
ssh: {
|
||||
autoStart: '開機自啟',
|
||||
|
@ -1215,6 +1215,7 @@ const message = {
|
||||
noNameFolder: '未命名文件夹',
|
||||
noNameFile: '未命名文件',
|
||||
minimap: '缩略图',
|
||||
fileCanNotRead: '此文件不支持预览',
|
||||
},
|
||||
ssh: {
|
||||
autoStart: '开机自启',
|
||||
|
Loading…
Reference in New Issue
Block a user