mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-17 14:15:29 +01:00
🎨 Warn users about potential performance issues when running on non-SSD drives https://github.com/siyuan-note/siyuan/issues/16835
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
94ae418708
commit
2df2f2eb3a
18 changed files with 82 additions and 18 deletions
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/denisbrodbeck/machineid"
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/go-ole/go-ole/oleutil"
|
||||
"github.com/jaypipes/ghw"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
|
@ -105,6 +106,45 @@ func logBootInfo() {
|
|||
if 0 < len(DisabledFeatures) {
|
||||
logging.LogInfof("disabled features [%s]", strings.Join(DisabledFeatures, ", "))
|
||||
}
|
||||
|
||||
if gulu.OS.IsWindows() || gulu.OS.IsLinux() {
|
||||
go func() {
|
||||
if ghw.DriveTypeSSD.String() != getWorkspaceDriveType() {
|
||||
logging.LogWarnf("workspace dir [%s] is not in SSD drive, performance may be affected", WorkspaceDir)
|
||||
WaitForUILoaded()
|
||||
time.Sleep(3 * time.Second)
|
||||
PushErrMsg(Langs[Lang][278], 15000)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func getWorkspaceDriveType() string {
|
||||
block, err := ghw.Block()
|
||||
if err != nil {
|
||||
logging.LogWarnf("get block storage info failed: %s", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
if gulu.OS.IsWindows() {
|
||||
part := filepath.VolumeName(WorkspaceDir)
|
||||
for _, disk := range block.Disks {
|
||||
for _, partition := range disk.Partitions {
|
||||
if partition.MountPoint == part {
|
||||
return partition.Disk.DriveType.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if gulu.OS.IsLinux() {
|
||||
for _, disk := range block.Disks {
|
||||
for _, partition := range disk.Partitions {
|
||||
if strings.HasPrefix(WorkspaceDir, partition.MountPoint) {
|
||||
return partition.Disk.DriveType.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func RandomSleep(minMills, maxMills int) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue