Skip to content

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

:art: Improve Linux disk type detection (#17361)

Jeffrey Chene6b4c29626e1
diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go
index 3e610db9f1..d00f501d3d 100644
--- a/kernel/util/runtime.go
+++ b/kernel/util/runtime.go
@@ -153,13 +153,37 @@ func getWorkspaceDriveType() string {
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 IsSubPath(partition.MountPoint, WorkspaceDir) {
- return partition.Disk.DriveType.String()
+ if partition.MountPoint == "" {
+ continue
+ }
+ mountPath := filepath.Clean(partition.MountPoint)
+ rel, err := filepath.Rel(mountPath, workspacePath)
+ if err != nil {
+ continue
+ }
+ if rel == ".." || strings.HasPrefix(rel, parentRelPrefix) {
+ continue
+ }
+ if len(mountPath) > maxMountPathLen {
+ maxMountPathLen = len(mountPath)
+ matchedDriveType = partition.Disk.DriveType.String()
}
}
}
+ return matchedDriveType
}
return ""
}