mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
🎨 macOS 端对工作空间放置在 iCloud 路径下做检查 https://github.com/siyuan-note/siyuan/issues/7747
This commit is contained in:
parent
3f9d32d6ff
commit
0323b89e95
1 changed files with 14 additions and 11 deletions
|
|
@ -19,6 +19,7 @@ package util
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -244,8 +245,8 @@ func checkFileSysStatus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsCloudDrivePath(absPath string) bool {
|
func IsCloudDrivePath(workspaceAbsPath string) bool {
|
||||||
absPathLower := strings.ToLower(absPath)
|
absPathLower := strings.ToLower(workspaceAbsPath)
|
||||||
if isICloudPath(absPathLower) {
|
if isICloudPath(absPathLower) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
@ -254,21 +255,23 @@ func IsCloudDrivePath(absPath string) bool {
|
||||||
strings.Contains(absPathLower, "google drive") || strings.Contains(absPathLower, "pcloud")
|
strings.Contains(absPathLower, "google drive") || strings.Contains(absPathLower, "pcloud")
|
||||||
}
|
}
|
||||||
|
|
||||||
func isICloudPath(absPath string) bool {
|
func isICloudPath(workspaceAbsPath string) (ret bool) {
|
||||||
if !gulu.OS.IsDarwin() {
|
if !gulu.OS.IsDarwin() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// macOS 端对工作空间放置在 iCloud 路径下做检查 https://github.com/siyuan-note/siyuan/issues/7747
|
// macOS 端对工作空间放置在 iCloud 路径下做检查 https://github.com/siyuan-note/siyuan/issues/7747
|
||||||
|
|
||||||
iCloudRoot := filepath.Join(HomeDir, "Library", "Mobile Documents")
|
iCloudRoot := filepath.Join(HomeDir, "Library", "Mobile Documents")
|
||||||
err := WalkWithSymlinks(iCloudRoot, func(path string, info os.FileInfo, err error) error {
|
WalkWithSymlinks(iCloudRoot, func(path string, info os.FileInfo, err error) error {
|
||||||
logging.LogInfof("path: %s", path)
|
if !info.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(workspaceAbsPath, strings.ToLower(path)) {
|
||||||
|
ret = true
|
||||||
|
return io.EOF
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if nil != err {
|
return
|
||||||
logging.LogErrorf("walk iCloud dir [%s] failed: %s", iCloudRoot, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue