This commit is contained in:
Liang Ding 2023-03-27 11:47:38 +08:00
parent f534675464
commit a85c61d3c1
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 57 additions and 39 deletions

View file

@ -473,9 +473,6 @@ const initKernel = (workspace, port, lang) => {
case 21: case 21:
errorWindowId = showErrorWindow("⚠️ 监听端口 " + currentKernelPort + " 失败 Failed to listen to port " + currentKernelPort, "<div>监听 " + currentKernelPort + " 端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to listen to port " + currentKernelPort + ", please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>"); errorWindowId = showErrorWindow("⚠️ 监听端口 " + currentKernelPort + " 失败 Failed to listen to port " + currentKernelPort, "<div>监听 " + currentKernelPort + " 端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to listen to port " + currentKernelPort + ", please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>");
break; break;
case 22:
errorWindowId = showErrorWindow("⚠️ 创建配置目录失败 Failed to create config directory", "<div>思源需要在用户家目录下创建配置文件夹(~/.config/siyuan请确保该路径具有写入权限。</div><div>SiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.</div>");
break;
case 24: // 工作空间已被锁定,尝试切换到第一个打开的工作空间 case 24: // 工作空间已被锁定,尝试切换到第一个打开的工作空间
if (workspaces && 0 < workspaces.length) { if (workspaces && 0 < workspaces.length) {
showWindow(workspaces[0].browserWindow); showWindow(workspaces[0].browserWindow);
@ -484,7 +481,7 @@ const initKernel = (workspace, port, lang) => {
errorWindowId = showErrorWindow("⚠️ 工作空间已被锁定 The workspace is locked", "<div>该工作空间正在被使用。</div><div>The workspace is in use.</div>"); errorWindowId = showErrorWindow("⚠️ 工作空间已被锁定 The workspace is locked", "<div>该工作空间正在被使用。</div><div>The workspace is in use.</div>");
break; break;
case 25: case 25:
errorWindowId = showErrorWindow("⚠️ 创建工作空间目录失败 Failed to create workspace directory", "<div>创建工作空间目录失败。</div><div>Failed to create workspace directory.</div>"); errorWindowId = showErrorWindow("⚠️ 初始化工作空间失败 Failed to create workspace directory", "<div>初始化工作空间失败。</div><div>Failed to init workspace.</div>");
break; break;
case 26: case 26:
errorWindowId = showErrorWindow("⚠️ 文件系统读写错误 File system access error", "<div>请检查文件系统权限,并确保没有其他程序正在读写文件;<br>请勿使用第三方同步盘进行数据同步否则数据会被损坏iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等)</div><div>Please check file system permissions and make sure no other programs are reading or writing to the file;<br>Do not use a third-party sync disk for data sync, otherwise the data will be damaged (OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)</div>"); errorWindowId = showErrorWindow("⚠️ 文件系统读写错误 File system access error", "<div>请检查文件系统权限,并确保没有其他程序正在读写文件;<br>请勿使用第三方同步盘进行数据同步否则数据会被损坏iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等)</div><div>Please check file system permissions and make sure no other programs are reading or writing to the file;<br>Do not use a third-party sync disk for data sync, otherwise the data will be damaged (OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)</div>");

View file

@ -48,7 +48,7 @@ require (
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
github.com/siyuan-note/filelock v0.0.0-20230321113304-79a32917cc9f github.com/siyuan-note/filelock v0.0.0-20230321113304-79a32917cc9f
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554 github.com/siyuan-note/logging v0.0.0-20230327034340-a7bed1fff2fe
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7 github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7
github.com/steambap/captcha v1.4.1 github.com/steambap/captcha v1.4.1
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2 github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2

View file

@ -293,6 +293,10 @@ github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc h1:MX2cPWpn
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc/go.mod h1:WDO42mUVRnkk8M4AhZ4oakZ5jnghulP0c8NFCrrFWG4= github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc/go.mod h1:WDO42mUVRnkk8M4AhZ4oakZ5jnghulP0c8NFCrrFWG4=
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554 h1:uaLbecIT6G7jFQUscXSzIxi/hDVSfzZccMCl8Lzqqn0= github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554 h1:uaLbecIT6G7jFQUscXSzIxi/hDVSfzZccMCl8Lzqqn0=
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4= github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
github.com/siyuan-note/logging v0.0.0-20230327031937-fad01e626ac2 h1:RuByEVw3s+R4ch/n1Wd5uBn0Gd/PDqNae2QoYi/Q+vQ=
github.com/siyuan-note/logging v0.0.0-20230327031937-fad01e626ac2/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
github.com/siyuan-note/logging v0.0.0-20230327034340-a7bed1fff2fe h1:QmBB+8HVbjxXzVUdAiysYaClEAaREcxeZt6kvHcrFUc=
github.com/siyuan-note/logging v0.0.0-20230327034340-a7bed1fff2fe/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7 h1:Kr8hhMhr6v+U24TMDCP5WdP4dWrXm5maar+TycTZs9I= github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7 h1:Kr8hhMhr6v+U24TMDCP5WdP4dWrXm5maar+TycTZs9I=
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7/go.mod h1:XJtLlKCr8cZE+lzykM4edHHih92M9M50UNw/nDLYRN8= github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7/go.mod h1:XJtLlKCr8cZE+lzykM4edHHih92M9M50UNw/nDLYRN8=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=

View file

@ -174,14 +174,23 @@ func ExportSystemLog() (zipPath string) {
logging.LogErrorf("copy app log from [%s] to [%s] failed: %s", err, appLog, to) logging.LogErrorf("copy app log from [%s] to [%s] failed: %s", err, appLog, to)
} }
} }
kernelLog := filepath.Join(util.TempDir, "siyuan.log")
kernelLog := filepath.Join(util.HomeDir, ".config", "siyuan", "kernel.log")
if gulu.File.IsExist(kernelLog) { if gulu.File.IsExist(kernelLog) {
to := filepath.Join(exportFolder, "siyuan.log") to := filepath.Join(exportFolder, "kernel.log")
if err := gulu.File.CopyFile(kernelLog, to); nil != err { if err := gulu.File.CopyFile(kernelLog, to); nil != err {
logging.LogErrorf("copy kernel log from [%s] to [%s] failed: %s", err, kernelLog, to) logging.LogErrorf("copy kernel log from [%s] to [%s] failed: %s", err, kernelLog, to)
} }
} }
siyuanLog := filepath.Join(util.TempDir, "siyuan.log")
if gulu.File.IsExist(siyuanLog) {
to := filepath.Join(exportFolder, "siyuan.log")
if err := gulu.File.CopyFile(siyuanLog, to); nil != err {
logging.LogErrorf("copy kernel log from [%s] to [%s] failed: %s", err, siyuanLog, to)
}
}
zipPath = exportFolder + ".zip" zipPath = exportFolder + ".zip"
zip, err := gulu.Zip.Create(zipPath) zip, err := gulu.Zip.Create(zipPath)
if nil != err { if nil != err {

View file

@ -244,12 +244,11 @@ func checkFileSysStatus() {
} }
func IsCloudDrivePath(workspaceAbsPath string) bool { func IsCloudDrivePath(workspaceAbsPath string) bool {
absPathLower := strings.ToLower(workspaceAbsPath) if isICloudPath(workspaceAbsPath) {
if isICloudPath(absPathLower) {
return true return true
} }
if isKnownCloudDrivePath(absPathLower) { if isKnownCloudDrivePath(workspaceAbsPath) {
return true return true
} }
@ -260,17 +259,20 @@ func IsCloudDrivePath(workspaceAbsPath string) bool {
return false return false
} }
func isKnownCloudDrivePath(workspaceAbsPathLower string) bool { func isKnownCloudDrivePath(workspaceAbsPath string) bool {
workspaceAbsPathLower := strings.ToLower(workspaceAbsPath)
return strings.Contains(workspaceAbsPathLower, "onedrive") || strings.Contains(workspaceAbsPathLower, "dropbox") || return strings.Contains(workspaceAbsPathLower, "onedrive") || strings.Contains(workspaceAbsPathLower, "dropbox") ||
strings.Contains(workspaceAbsPathLower, "google drive") || strings.Contains(workspaceAbsPathLower, "pcloud") || strings.Contains(workspaceAbsPathLower, "google drive") || strings.Contains(workspaceAbsPathLower, "pcloud") ||
strings.Contains(workspaceAbsPathLower, "坚果云") strings.Contains(workspaceAbsPathLower, "坚果云")
} }
func isICloudPath(workspaceAbsPathLower string) (ret bool) { func isICloudPath(workspaceAbsPath string) (ret bool) {
if !gulu.OS.IsDarwin() { if !gulu.OS.IsDarwin() {
return false return false
} }
workspaceAbsPathLower := strings.ToLower(workspaceAbsPath)
// macOS 端对工作空间放置在 iCloud 路径下做检查 https://github.com/siyuan-note/siyuan/issues/7747 // macOS 端对工作空间放置在 iCloud 路径下做检查 https://github.com/siyuan-note/siyuan/issues/7747
iCloudRoot := filepath.Join(HomeDir, "Library", "Mobile Documents") iCloudRoot := filepath.Join(HomeDir, "Library", "Mobile Documents")
WalkWithSymlinks(iCloudRoot, func(path string, info os.FileInfo, err error) error { WalkWithSymlinks(iCloudRoot, func(path string, info os.FileInfo, err error) error {

View file

@ -21,7 +21,6 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"log"
"math/rand" "math/rand"
"mime" "mime"
"os" "os"
@ -186,10 +185,12 @@ var (
func initWorkspaceDir(workspaceArg string) { func initWorkspaceDir(workspaceArg string) {
userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan") userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan")
workspaceConf := filepath.Join(userHomeConfDir, "workspace.json") workspaceConf := filepath.Join(userHomeConfDir, "workspace.json")
logging.SetLogPath(filepath.Join(userHomeConfDir, "kernel.log"))
if !gulu.File.IsExist(workspaceConf) { if !gulu.File.IsExist(workspaceConf) {
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err) logging.LogErrorf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
os.Exit(logging.ExitCodeCreateConfDirErr) os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
} }
@ -201,8 +202,8 @@ func initWorkspaceDir(workspaceArg string) {
} }
} }
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
log.Printf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err) logging.LogErrorf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
os.Exit(logging.ExitCodeCreateWorkspaceDirErr) os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
var workspacePaths []string var workspacePaths []string
@ -226,13 +227,14 @@ func initWorkspaceDir(workspaceArg string) {
} }
if !gulu.File.IsDir(WorkspaceDir) { if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir) logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
WorkspaceDir = defaultWorkspaceDir WorkspaceDir = defaultWorkspaceDir
} }
workspacePaths = append(workspacePaths, WorkspaceDir) workspacePaths = append(workspacePaths, WorkspaceDir)
if err := WriteWorkspacePaths(workspacePaths); nil != err { if err := WriteWorkspacePaths(workspacePaths); nil != err {
log.Fatalf("write workspace conf [%s] failed: %s", workspaceConf, err) logging.LogErrorf("write workspace conf [%s] failed: %s", workspaceConf, err)
os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
ConfDir = filepath.Join(WorkspaceDir, "conf") ConfDir = filepath.Join(WorkspaceDir, "conf")
@ -243,7 +245,8 @@ func initWorkspaceDir(workspaceArg string) {
osTmpDir := filepath.Join(TempDir, "os") osTmpDir := filepath.Join(TempDir, "os")
os.RemoveAll(osTmpDir) os.RemoveAll(osTmpDir)
if err := os.MkdirAll(osTmpDir, 0755); nil != err { if err := os.MkdirAll(osTmpDir, 0755); nil != err {
log.Fatalf("create os tmp dir [%s] failed: %s", osTmpDir, err) logging.LogErrorf("create os tmp dir [%s] failed: %s", osTmpDir, err)
os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
os.RemoveAll(filepath.Join(TempDir, "repo")) os.RemoveAll(filepath.Join(TempDir, "repo"))
os.Setenv("TMPDIR", osTmpDir) os.Setenv("TMPDIR", osTmpDir)
@ -327,33 +330,33 @@ const (
func initPathDir() { func initPathDir() {
if err := os.MkdirAll(ConfDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(ConfDir, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create conf folder [%s] failed: %s", ConfDir, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create conf folder [%s] failed: %s", ConfDir, err)
} }
if err := os.MkdirAll(DataDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(DataDir, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create data folder [%s] failed: %s", DataDir, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data folder [%s] failed: %s", DataDir, err)
} }
if err := os.MkdirAll(TempDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(TempDir, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create temp folder [%s] failed: %s", TempDir, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create temp folder [%s] failed: %s", TempDir, err)
} }
assets := filepath.Join(DataDir, "assets") assets := filepath.Join(DataDir, "assets")
if err := os.MkdirAll(assets, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(assets, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create data assets folder [%s] failed: %s", assets, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data assets folder [%s] failed: %s", assets, err)
} }
templates := filepath.Join(DataDir, "templates") templates := filepath.Join(DataDir, "templates")
if err := os.MkdirAll(templates, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(templates, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create data templates folder [%s] failed: %s", templates, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data templates folder [%s] failed: %s", templates, err)
} }
widgets := filepath.Join(DataDir, "widgets") widgets := filepath.Join(DataDir, "widgets")
if err := os.MkdirAll(widgets, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(widgets, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create data widgets folder [%s] failed: %s", widgets, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data widgets folder [%s] failed: %s", widgets, err)
} }
emojis := filepath.Join(DataDir, "emojis") emojis := filepath.Join(DataDir, "emojis")
if err := os.MkdirAll(emojis, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(emojis, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create data emojis folder [%s] failed: %s", widgets, err) logging.LogFatalf(logging.ExitCodeInitWorkspaceErr, "create data emojis folder [%s] failed: %s", widgets, err)
} }
} }

View file

@ -17,7 +17,6 @@
package util package util
import ( import (
"log"
"math/rand" "math/rand"
"os" "os"
"path/filepath" "path/filepath"
@ -43,18 +42,20 @@ func BootMobile(container, appDir, workspaceBaseDir, lang string) {
WorkingDir = filepath.Join(appDir, "app") WorkingDir = filepath.Join(appDir, "app")
HomeDir = filepath.Join(workspaceBaseDir, "home") HomeDir = filepath.Join(workspaceBaseDir, "home")
userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan") userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan")
logging.SetLogPath(filepath.Join(userHomeConfDir, "kernel.log"))
if !gulu.File.IsExist(userHomeConfDir) { if !gulu.File.IsExist(userHomeConfDir) {
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err) logging.LogErrorf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
os.Exit(logging.ExitCodeCreateConfDirErr) os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
} }
defaultWorkspaceDir := filepath.Join(workspaceBaseDir, "siyuan") defaultWorkspaceDir := filepath.Join(workspaceBaseDir, "siyuan")
if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) { if err := os.MkdirAll(defaultWorkspaceDir, 0755); nil != err && !os.IsExist(err) {
log.Printf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err) logging.LogErrorf("create default workspace folder [%s] failed: %s", defaultWorkspaceDir, err)
os.Exit(logging.ExitCodeCreateWorkspaceDirErr) os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
initWorkspaceDirMobile(workspaceBaseDir) initWorkspaceDirMobile(workspaceBaseDir)
@ -69,7 +70,7 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
if gulu.File.IsDir(workspaceBaseDir) { if gulu.File.IsDir(workspaceBaseDir) {
entries, err := os.ReadDir(workspaceBaseDir) entries, err := os.ReadDir(workspaceBaseDir)
if nil != err { if nil != err {
log.Printf("read workspace dir [%s] failed: %s", workspaceBaseDir, err) logging.LogErrorf("read workspace dir [%s] failed: %s", workspaceBaseDir, err)
} else { } else {
// 旧版 iOS 端会在 workspaceBaseDir 下直接创建工作空间,这里需要将数据迁移到 workspaceBaseDir/siyuan/ 文件夹下 // 旧版 iOS 端会在 workspaceBaseDir 下直接创建工作空间,这里需要将数据迁移到 workspaceBaseDir/siyuan/ 文件夹下
var oldConf, oldData, oldTemp bool var oldConf, oldData, oldTemp bool
@ -96,9 +97,9 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
from := filepath.Join(workspaceBaseDir, entry.Name()) from := filepath.Join(workspaceBaseDir, entry.Name())
to := filepath.Join(workspaceBaseDir, "siyuan", entry.Name()) to := filepath.Join(workspaceBaseDir, "siyuan", entry.Name())
if err = os.Rename(from, to); nil != err { if err = os.Rename(from, to); nil != err {
log.Printf("move workspace dir [%s] failed: %s", workspaceBaseDir, err) logging.LogErrorf("move workspace dir [%s] failed: %s", workspaceBaseDir, err)
} else { } else {
log.Printf("moved workspace dir [fomr=%s, to=%s]", from, to) logging.LogInfof("moved workspace dir [fomr=%s, to=%s]", from, to)
} }
} }
@ -116,7 +117,7 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
if !gulu.File.IsExist(workspaceConf) { if !gulu.File.IsExist(workspaceConf) {
WorkspaceDir = defaultWorkspaceDir WorkspaceDir = defaultWorkspaceDir
if !gulu.File.IsDir(WorkspaceDir) { if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir) logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
WorkspaceDir = defaultWorkspaceDir WorkspaceDir = defaultWorkspaceDir
} }
workspacePaths = append(workspacePaths, WorkspaceDir) workspacePaths = append(workspacePaths, WorkspaceDir)
@ -125,7 +126,7 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
if 0 < len(workspacePaths) { if 0 < len(workspacePaths) {
WorkspaceDir = workspacePaths[len(workspacePaths)-1] WorkspaceDir = workspacePaths[len(workspacePaths)-1]
if !gulu.File.IsDir(WorkspaceDir) { if !gulu.File.IsDir(WorkspaceDir) {
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", defaultWorkspaceDir, WorkspaceDir) logging.LogWarnf("use the default workspace [%s] since the specified workspace [%s] is not a dir", defaultWorkspaceDir, WorkspaceDir)
WorkspaceDir = defaultWorkspaceDir WorkspaceDir = defaultWorkspaceDir
} }
workspacePaths[len(workspacePaths)-1] = WorkspaceDir workspacePaths[len(workspacePaths)-1] = WorkspaceDir
@ -136,7 +137,8 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
} }
if err := WriteWorkspacePaths(workspacePaths); nil != err { if err := WriteWorkspacePaths(workspacePaths); nil != err {
log.Fatalf("write workspace conf [%s] failed: %s", workspaceConf, err) logging.LogErrorf("write workspace conf [%s] failed: %s", workspaceConf, err)
os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
ConfDir = filepath.Join(WorkspaceDir, "conf") ConfDir = filepath.Join(WorkspaceDir, "conf")
@ -147,7 +149,8 @@ func initWorkspaceDirMobile(workspaceBaseDir string) {
osTmpDir := filepath.Join(TempDir, "os") osTmpDir := filepath.Join(TempDir, "os")
os.RemoveAll(osTmpDir) os.RemoveAll(osTmpDir)
if err := os.MkdirAll(osTmpDir, 0755); nil != err { if err := os.MkdirAll(osTmpDir, 0755); nil != err {
log.Fatalf("create os tmp dir [%s] failed: %s", osTmpDir, err) logging.LogErrorf("create os tmp dir [%s] failed: %s", osTmpDir, err)
os.Exit(logging.ExitCodeInitWorkspaceErr)
} }
os.RemoveAll(filepath.Join(TempDir, "repo")) os.RemoveAll(filepath.Join(TempDir, "repo"))
os.Setenv("TMPDIR", osTmpDir) os.Setenv("TMPDIR", osTmpDir)