mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-16 03:58:07 +01:00
♻️ 将退出码移到 logging 项目中
This commit is contained in:
parent
e99b7fd588
commit
2601605953
13 changed files with 29 additions and 39 deletions
|
|
@ -37,18 +37,6 @@ import (
|
|||
|
||||
const DatabaseVer = "20220501" // 修改表结构的话需要修改这里
|
||||
|
||||
const (
|
||||
ExitCodeReadOnlyDatabase = 20 // 数据库文件被锁
|
||||
ExitCodeUnavailablePort = 21 // 端口不可用
|
||||
ExitCodeCreateConfDirErr = 22 // 创建配置目录失败
|
||||
ExitCodeBlockTreeErr = 23 // 无法读写 blocktree.msgpack 文件
|
||||
ExitCodeWorkspaceLocked = 24 // 工作空间已被锁定
|
||||
ExitCodeCreateWorkspaceDirErr = 25 // 创建工作空间失败
|
||||
ExitCodeFileSysInconsistent = 26 // 文件系统不一致
|
||||
ExitCodeOk = 0 // 正常退出
|
||||
ExitCodeFatal = 1 // 致命错误
|
||||
)
|
||||
|
||||
// IsExiting 是否正在退出程序。
|
||||
var IsExiting = false
|
||||
|
||||
|
|
@ -139,7 +127,7 @@ func ReportFileSysFatalError(err error) {
|
|||
output = strings.Join(lines[5:], "\n")
|
||||
}
|
||||
logging.LogErrorf("check file system status failed: %s, %s", err, output)
|
||||
os.Exit(ExitCodeFileSysInconsistent)
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
}
|
||||
|
||||
func CheckFileSysStatus() {
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ func initWorkspaceDir(workspaceArg string) {
|
|||
if !gulu.File.IsExist(workspaceConf) {
|
||||
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
|
||||
os.Exit(ExitCodeCreateConfDirErr)
|
||||
os.Exit(logging.ExitCodeCreateConfDirErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ func initWorkspaceDir(workspaceArg string) {
|
|||
}
|
||||
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
|
||||
os.Exit(ExitCodeCreateWorkspaceDirErr)
|
||||
os.Exit(logging.ExitCodeCreateWorkspaceDirErr)
|
||||
}
|
||||
|
||||
var workspacePaths []string
|
||||
|
|
@ -481,7 +481,7 @@ func tryLockWorkspace() {
|
|||
} else {
|
||||
logging.LogErrorf("lock workspace [%s] failed", WorkspaceDir)
|
||||
}
|
||||
os.Exit(ExitCodeWorkspaceLocked)
|
||||
os.Exit(logging.ExitCodeWorkspaceLocked)
|
||||
}
|
||||
|
||||
func IsWorkspaceLocked(workspacePath string) bool {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func BootMobile(container, appDir, workspaceBaseDir, lang string) {
|
|||
if !gulu.File.IsExist(userHomeConfDir) {
|
||||
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
|
||||
os.Exit(ExitCodeCreateConfDirErr)
|
||||
os.Exit(logging.ExitCodeCreateConfDirErr)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ func BootMobile(container, appDir, workspaceBaseDir, lang string) {
|
|||
defaultWorkspaceDir := filepath.Join(workspaceBaseDir, "siyuan")
|
||||
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
|
||||
log.Printf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
|
||||
os.Exit(ExitCodeCreateWorkspaceDirErr)
|
||||
os.Exit(logging.ExitCodeCreateWorkspaceDirErr)
|
||||
}
|
||||
|
||||
initWorkspaceDirMobile(workspaceBaseDir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue