Skip to content

Commit

Permalink
🎨 Documents/SiYuan/ is no longer created if a configured workspace ex…
Browse files Browse the repository at this point in the history
…ists Fix #8566
  • Loading branch information
88250 committed Jun 17, 2023
1 parent c37f6f5 commit 7d3af3a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions kernel/util/working.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,34 +196,30 @@ func initWorkspaceDir(workspaceArg string) {
defaultWorkspaceDir = filepath.Join(userProfile, "Documents", "SiYuan")
}
}
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
logging.LogErrorf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
os.Exit(logging.ExitCodeInitWorkspaceErr)
}

var workspacePaths []string
if !gulu.File.IsExist(workspaceConf) {
WorkspaceDir = defaultWorkspaceDir
if "" != workspaceArg {
WorkspaceDir = workspaceArg
}
} else {
workspacePaths, _ = ReadWorkspacePaths()

if 0 < len(workspacePaths) {
// 取最后一个(也就是最近打开的)工作空间
WorkspaceDir = workspacePaths[len(workspacePaths)-1]
} else {
WorkspaceDir = defaultWorkspaceDir
}
}

if "" != workspaceArg {
WorkspaceDir = workspaceArg
}
if "" != workspaceArg {
WorkspaceDir = workspaceArg
}

if !gulu.File.IsDir(WorkspaceDir) {
logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
logging.LogErrorf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
os.Exit(logging.ExitCodeInitWorkspaceErr)
}
WorkspaceDir = defaultWorkspaceDir
}
workspacePaths = append(workspacePaths, WorkspaceDir)
Expand Down

0 comments on commit 7d3af3a

Please sign in to comment.