skip symlink file for upload mode

This commit is contained in:
tickstep 2024-03-16 20:44:19 +08:00
parent 3fcbbe9b40
commit 25202861c5
2 changed files with 17 additions and 1 deletions

View File

@ -209,7 +209,7 @@ func (t *SyncTask) Start() error {
} else if t.Mode == DownloadOnly {
go t.scanPanFile(t.ctx)
} else {
return fmt.Errorf("异常:暂不支持该模式。")
return fmt.Errorf("异常:暂不支持该模式。")
}
return nil
@ -479,6 +479,12 @@ func (t *SyncTask) scanLocalFile(ctx context.Context) {
continue
}
// 跳过软链接文件
if IsSymlinkFile(file) {
logger.Verboseln("软链接文件,跳过:" + item.path + "/" + file.Name())
continue
}
logger.Verboseln("扫描到本地文件:" + item.path + "/" + file.Name())
// 文件夹需要增加到扫描队列
if file.IsDir() {

View File

@ -1,6 +1,8 @@
package syncdrive
import (
"io/fs"
"os"
"path"
"strings"
)
@ -22,3 +24,11 @@ func GetLocalFileFullPathFromPanPath(panFilePath, localRootPath, panRootPath str
relativePath := strings.TrimPrefix(panFilePath, panRootPath)
return path.Join(path.Clean(localRootPath), relativePath)
}
// IsSymlinkFile 是否是软链接文件
func IsSymlinkFile(file fs.FileInfo) bool {
if file.Mode()&os.ModeSymlink != 0 {
return true
}
return false
}