Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/pull/17361

Danielad79d83027bd
diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go
index d00f501d3d..d0e51b6231 100644
--- a/kernel/util/runtime.go
+++ b/kernel/util/runtime.go
@@ -131,39 +131,27 @@ func getWorkspaceDriveType() string {
return ghw.DriveTypeSSD.String()
}
- if gulu.OS.IsWindows() {
- block, err := ghw.Block()
- if err != nil {
- logging.LogWarnf("get block storage info failed: %s", err)
- return ""
- }
+ block, err := ghw.Block()
+ if err != nil {
+ logging.LogWarnf("get block storage info failed: %s", err)
+ return ""
+ }
+
+ var maxMountPathLen int
+ var matchedDriveType string
+ parentRelPrefix := ".." + string(filepath.Separator)
+ workspacePath := filepath.Clean(WorkspaceDir)
- part := filepath.VolumeName(WorkspaceDir)
+ if gulu.OS.IsWindows() {
+ vol := strings.ToLower(filepath.VolumeName(workspacePath))
for _, disk := range block.Disks {
for _, partition := range disk.Partitions {
- if partition.MountPoint == part {
+ if strings.EqualFold(strings.TrimSuffix(partition.MountPoint, "\\"), vol) {
return partition.Disk.DriveType.String()
}
}
}
} else if gulu.OS.IsLinux() {
- block, err := ghw.Block()
- if err != nil {
- logging.LogWarnf("get block storage info failed: %s", err)
- return ""
- }
-
- workspacePath := filepath.Clean(WorkspaceDir)
- if !filepath.IsAbs(workspacePath) {
- abs, err := filepath.Abs(workspacePath)
- if err != nil {
- return ""
- }
- workspacePath = abs
- }
- var maxMountPathLen int
- var matchedDriveType string
- parentRelPrefix := ".." + string(filepath.Separator)
for _, disk := range block.Disks {
for _, partition := range disk.Partitions {
if partition.MountPoint == "" {
@@ -177,15 +165,16 @@ func getWorkspaceDriveType() string {
if rel == ".." || strings.HasPrefix(rel, parentRelPrefix) {
continue
}
- if len(mountPath) > maxMountPathLen {
+
+ // 选路径最长的挂载点(如 /home/data 优于 /)
+ if len(mountPath) >= maxMountPathLen {
maxMountPathLen = len(mountPath)
matchedDriveType = partition.Disk.DriveType.String()
}
}
}
- return matchedDriveType
}
- return ""
+ return matchedDriveType
}
func RandomSleep(minMills, maxMills int) {