fix: 解决软连接被识别为文件问题 (#6400)

Refs #5879
This commit is contained in:
2024-09-06 17:37:52 +08:00 committed by GitHub
parent dd1430dbbf
commit a53fff2416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View File

@ -102,6 +102,12 @@ 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
}
file.IsDir = targetInfo.IsDir()
file.Extension = filepath.Ext(file.LinkPath)
}
if op.Expand {
if err := handleExpansion(file, op); err != nil {
@ -309,6 +315,12 @@ func (f *FileInfo) processFiles(files []FileSearchInfo, option FileOption) ([]*F
}
if isSymlink {
file.LinkPath = GetSymlink(fPath)
targetInfo, err := file.Fs.Stat(file.LinkPath)
if err != nil {
return nil, err
}
file.IsDir = targetInfo.IsDir()
file.Extension = filepath.Ext(file.LinkPath)
}
if df.Size() > 0 {
file.MimeType = GetMimeType(fPath)

View File

@ -11,7 +11,7 @@ export namespace File {
size: number;
isDir: boolean;
isSymlink: boolean;
linkPath: boolean;
linkPath: string;
type: string;
updateTime: string;
modTime: string;

View File

@ -891,12 +891,12 @@ const openView = (item: File.File) => {
compress: openDeCompress,
text: () => openCodeEditor(item.path, item.extension),
};
return actionMap[fileType] ? actionMap[fileType](item) : openCodeEditor(item.path, item.extension);
const path = item.isSymlink ? item.linkPath : item.path;
return actionMap[fileType] ? actionMap[fileType](item) : openCodeEditor(path, item.extension);
};
const openPreview = (item: File.File, fileType: string) => {
filePreview.path = item.path;
filePreview.path = item.isSymlink ? item.linkPath : item.path;
filePreview.name = item.name;
filePreview.extension = item.extension;
filePreview.fileType = fileType;