🐛 多个桌面端快捷方式指定不同的 --workspace 参数后无法启动多个工作空间 https://github.com/siyuan-note/siyuan/issues/7059

This commit is contained in:
Liang Ding 2023-01-14 11:26:24 +08:00
parent 6b298f3f24
commit d7577ffb61
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -212,36 +212,26 @@ func initWorkspaceDir(workspaceArg string) {
if "" != workspaceArg {
WorkspaceDir = workspaceArg
}
if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", defaultWorkspaceDir, WorkspaceDir)
WorkspaceDir = defaultWorkspaceDir
}
workspacePaths = append(workspacePaths, WorkspaceDir)
} else {
workspacePaths, _ = ReadWorkspacePaths()
if 0 < len(workspacePaths) {
// 取最后一个(也就是最近打开的)工作空间
WorkspaceDir = workspacePaths[len(workspacePaths)-1]
if "" != workspaceArg {
WorkspaceDir = workspaceArg
}
if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
WorkspaceDir = defaultWorkspaceDir
}
workspacePaths[len(workspacePaths)-1] = WorkspaceDir
} else {
WorkspaceDir = defaultWorkspaceDir
if "" != workspaceArg {
WorkspaceDir = workspaceArg
}
if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
WorkspaceDir = defaultWorkspaceDir
}
workspacePaths = append(workspacePaths, WorkspaceDir)
}
if "" != workspaceArg {
WorkspaceDir = workspaceArg
}
}
if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
WorkspaceDir = defaultWorkspaceDir
}
workspacePaths = append(workspacePaths, WorkspaceDir)
if err := WriteWorkspacePaths(workspacePaths); nil != err {
log.Fatalf("write workspace conf [%s] failed: %s", workspaceConf, err)
}
@ -284,8 +274,6 @@ func ReadWorkspacePaths() (ret []string, err error) {
return
}
ret = gulu.Str.RemoveDuplicatedElem(ret)
var tmp []string
for _, d := range ret {
d = strings.TrimRight(d, " \t\n") // 去掉工作空间路径尾部空格 https://github.com/siyuan-note/siyuan/issues/6353
@ -294,6 +282,7 @@ func ReadWorkspacePaths() (ret []string, err error) {
}
}
ret = tmp
ret = gulu.Str.RemoveDuplicatedElem(ret)
return
}