diff --git a/internal/syncdrive/sync_task.go b/internal/syncdrive/sync_task.go index 30004fc..197a3ef 100644 --- a/internal/syncdrive/sync_task.go +++ b/internal/syncdrive/sync_task.go @@ -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() { diff --git a/internal/syncdrive/utils.go b/internal/syncdrive/utils.go index 5a0270a..8c83c7e 100644 --- a/internal/syncdrive/utils.go +++ b/internal/syncdrive/utils.go @@ -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 +}