mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-29 21:08:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
c524dcf7ad
21 changed files with 99 additions and 218 deletions
|
|
@ -1000,7 +1000,7 @@
|
|||
"73": "Importing, please wait...",
|
||||
"74": "The kernel has not been fully booted [%d%%], please try again later",
|
||||
"75": "Attempt to access file failed",
|
||||
"76": "The data file has been locked by another program.",
|
||||
"76": "TODO",
|
||||
"77": "Invalid dir path [%s]",
|
||||
"78": "The old and new paths are repeated",
|
||||
"79": "Only supports importing Markdown document",
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@
|
|||
"73": "Importando, por favor espere...",
|
||||
"74": "El kernel no ha sido arrancado completamente [%d%%], por favor, inténtelo de nuevo más tarde",
|
||||
"75": "Error al intentar acceder al archivo",
|
||||
"76": "El archivo de datos ha sido bloqueado por otro programa.",
|
||||
"76": "TODO",
|
||||
"77": "Ruta inválida [%s]",
|
||||
"78": "Los viejos y nuevos caminos se repiten",
|
||||
"79": "Sólo admite la importación de documentos Markdown",
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@
|
|||
"73": "En cours d'importation, veuillez patienter...",
|
||||
"74": "Le kernel n'a pas été complètement démarré [%d%%], veuillez réessayer plus tard.",
|
||||
"75": "La tentative d'accès au fichier a échoué",
|
||||
"76": "Le fichier de données a été verrouillé par un autre programme.",
|
||||
"76": "TODO",
|
||||
"77": "Chemin d'accès invalide [%s]",
|
||||
"78": "Les anciens et les nouveaux chemins sont répétés",
|
||||
"79": "Prise en charge de l'importation de documents Markdown uniquement",
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@
|
|||
"73": "正在導入,請稍等...",
|
||||
"74": "kernel尚未完全啟動 [%d%%],請稍後再試",
|
||||
"75": "嘗試訪問資料檔失敗",
|
||||
"76": "資料檔案已被其他程式鎖定。",
|
||||
"76": "TODO",
|
||||
"77": "不可用的目錄路徑 [%s]",
|
||||
"78": "新老路徑重複",
|
||||
"79": "僅支援導入 Markdown 文檔",
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@
|
|||
"73": "正在导入,请稍等...",
|
||||
"74": "内核尚未完全启动 [%d%%],请稍后再试",
|
||||
"75": "尝试访问文件失败",
|
||||
"76": "数据文件已被其他程序锁定。",
|
||||
"76": "TODO",
|
||||
"77": "不可用的目录路径 [%s]",
|
||||
"78": "新老路径重复",
|
||||
"79": "仅支持导入 Markdown 文档",
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ const exitApp = (type, id) => {
|
|||
}
|
||||
} else {
|
||||
const currentURL = new URL(item.browserWindow.getURL());
|
||||
if (currentURL.port === id) {
|
||||
if (currentURL.port === id || currentURL.port === id.toString()) {
|
||||
mainWindow = item.browserWindow;
|
||||
if (workspaces.length > 1) {
|
||||
item.browserWindow.destroy();
|
||||
|
|
@ -486,7 +486,6 @@ const initKernel = (workspace, port, lang) => {
|
|||
let cmd = `ui version [${appVer}], booting kernel [${kernelPath} ${cmds.join(
|
||||
" ")}]`;
|
||||
writeLog(cmd);
|
||||
let kernelProcessPid = "";
|
||||
if (!isDevEnv || workspaces.length > 0) {
|
||||
const cp = require("child_process");
|
||||
const kernelProcess = cp.spawn(kernelPath,
|
||||
|
|
@ -495,12 +494,13 @@ const initKernel = (workspace, port, lang) => {
|
|||
stdio: "ignore",
|
||||
},
|
||||
);
|
||||
kernelProcessPid = kernelProcess.pid;
|
||||
writeLog("booted kernel process [pid=" + kernelProcessPid + ", port=" +
|
||||
kernelPort + "]");
|
||||
|
||||
const currentKernelPid = kernelProcess.pid;
|
||||
const currentKernelPort = kernelPort;
|
||||
writeLog("booted kernel process [pid=" + currentKernelPid + ", port=" + currentKernelPort + "]");
|
||||
|
||||
kernelProcess.on("close", (code) => {
|
||||
writeLog(`kernel [pid=${kernelProcessPid}] exited with code [${code}]`);
|
||||
writeLog(`kernel [pid=${currentKernelPid}, port=${currentKernelPort}] exited with code [${code}]`);
|
||||
if (0 !== code) {
|
||||
switch (code) {
|
||||
case 20:
|
||||
|
|
@ -508,53 +508,40 @@ const initKernel = (workspace, port, lang) => {
|
|||
"<div>数据库文件正在被其他进程占用,请检查是否同时存在多个内核进程(SiYuan Kernel)服务相同的工作空间。</div><div>The database file is being occupied by other processes, please check whether there are multiple kernel processes (SiYuan Kernel) serving the same workspace at the same time.</div>");
|
||||
break;
|
||||
case 21:
|
||||
showErrorWindow("⚠️ 监听端口 " + kernelPort +
|
||||
" 失败 Failed to listen to port " + kernelPort,
|
||||
"<div>监听 " + kernelPort +
|
||||
" 端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to listen to port " +
|
||||
kernelPort +
|
||||
", please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>");
|
||||
showErrorWindow("⚠️ 监听端口 " + kernelPort + " 失败 Failed to listen to port " + kernelPort,
|
||||
"<div>监听 " + kernelPort + " 端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to listen to port " + kernelPort + ", please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>");
|
||||
break;
|
||||
case 22:
|
||||
showErrorWindow(
|
||||
"⚠️ 创建配置目录失败 Failed to create config directory",
|
||||
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 23:
|
||||
showErrorWindow(
|
||||
"⚠️ 无法读写块树文件 Failed to access blocktree file",
|
||||
"<div>块树文件正在被其他程序锁定或者已经损坏,请删除 工作空间/temp/ 文件夹后重启</div><div>The block tree file is being locked by another program or is corrupted, please delete the workspace/temp/ folder and restart.</div>");
|
||||
break;
|
||||
case 24: // 工作空间已被锁定,尝试切换到第一个打开的工作空间
|
||||
if (workspaces && 0 < workspaces.length) {
|
||||
showWindow(workspaces[0].browserWindow);
|
||||
}
|
||||
|
||||
showErrorWindow(
|
||||
"⚠️ 工作空间已被锁定 The workspace is locked",
|
||||
showErrorWindow("⚠️ 工作空间已被锁定 The workspace is locked",
|
||||
"<div>该工作空间正在被使用。</div><div>The workspace is in use.</div>");
|
||||
break;
|
||||
case 25:
|
||||
showErrorWindow(
|
||||
"⚠️ 创建工作空间目录失败 Failed to create workspace directory",
|
||||
showErrorWindow("⚠️ 创建工作空间目录失败 Failed to create workspace directory",
|
||||
"<div>创建工作空间目录失败。</div><div>Failed to create workspace directory.</div>");
|
||||
break;
|
||||
case 26:
|
||||
showErrorWindow(
|
||||
"⚠️ 文件系统不一致 File system inconsistent",
|
||||
"<div>请勿使用第三方同步盘进行数据同步,否则数据会被损坏(iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等)</div><div>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>");
|
||||
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>");
|
||||
break;
|
||||
case 0:
|
||||
case 1: // Fatal error
|
||||
break;
|
||||
default:
|
||||
showErrorWindow(
|
||||
"⚠️ 内核因未知原因退出 The kernel exited for unknown reasons",
|
||||
showErrorWindow("⚠️ 内核因未知原因退出 The kernel exited for unknown reasons",
|
||||
`<div>思源内核因未知原因退出 [code=${code}],请尝试重启操作系统后再启动思源。如果该问题依然发生,请检查杀毒软件是否阻止思源内核启动。</div>
|
||||
<div>SiYuan Kernel exited for unknown reasons [code=${code}], please try to reboot your operating system and then start SiYuan again. If occurs this problem still, please check your anti-virus software whether kill the SiYuan Kernel.</div>`);
|
||||
break;
|
||||
}
|
||||
exitApp("port", kernelPort);
|
||||
|
||||
exitApp("port", currentKernelPort);
|
||||
bootWindow.destroy();
|
||||
resolve(false);
|
||||
}
|
||||
|
|
@ -580,8 +567,7 @@ const initKernel = (workspace, port, lang) => {
|
|||
count++;
|
||||
if (14 < count) {
|
||||
writeLog("get kernel ver failed");
|
||||
showErrorWindow(
|
||||
"⚠️ 获取内核服务端口失败 Failed to get kernel serve port",
|
||||
showErrorWindow("⚠️ 获取内核服务端口失败 Failed to get kernel serve port",
|
||||
"<div>获取内核服务端口失败,请确保程序拥有网络权限并不受防火墙和杀毒软件阻止。</div><div>Failed to get kernel serve port, please make sure the program has network permissions and is not blocked by firewalls and antivirus software.</div>");
|
||||
bootWindow.destroy();
|
||||
resolve(false);
|
||||
|
|
@ -605,8 +591,7 @@ const initKernel = (workspace, port, lang) => {
|
|||
let progressing = false;
|
||||
while (!progressing) {
|
||||
try {
|
||||
const progressResult = await fetch(
|
||||
getServer() + "/api/system/bootProgress");
|
||||
const progressResult = await fetch(getServer() + "/api/system/bootProgress");
|
||||
const progressData = await progressResult.json();
|
||||
if (progressData.data.progress >= 100) {
|
||||
resolve(true);
|
||||
|
|
@ -643,9 +628,7 @@ app.whenReady().then(() => {
|
|||
const resetTrayMenu = (tray, lang, mainWindow) => {
|
||||
const trayMenuTemplate = [
|
||||
{
|
||||
label: mainWindow.isVisible()
|
||||
? lang.hideWindow
|
||||
: lang.showWindow,
|
||||
label: mainWindow.isVisible() ? lang.hideWindow : lang.showWindow,
|
||||
click: () => {
|
||||
showHideWindow(tray, lang, mainWindow);
|
||||
},
|
||||
|
|
@ -681,9 +664,7 @@ app.whenReady().then(() => {
|
|||
if ("win32" === process.platform) {
|
||||
// Windows 端支持窗口置顶 https://github.com/siyuan-note/siyuan/issues/6860
|
||||
trayMenuTemplate.splice(1, 0, {
|
||||
label: mainWindow.isAlwaysOnTop()
|
||||
? lang.cancelWindowTop
|
||||
: lang.setWindowTop,
|
||||
label: mainWindow.isAlwaysOnTop() ? lang.cancelWindowTop : lang.setWindowTop,
|
||||
click: () => {
|
||||
if (!mainWindow.isAlwaysOnTop()) {
|
||||
mainWindow.setAlwaysOnTop(true);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -195,11 +194,12 @@ func checkBlockExist(c *gin.Context) {
|
|||
|
||||
id := arg["id"].(string)
|
||||
b, err := model.GetBlock(id, nil)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
// TODO 文件被锁的情况已经在 filelock 中做了退出进程处理,不会走到应用层,所以 code 为 2 的情况应该移除
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 0
|
||||
ret.Data = false
|
||||
|
|
@ -405,11 +405,11 @@ func getBlockInfo(c *gin.Context) {
|
|||
id := arg["id"].(string)
|
||||
|
||||
tree, err := model.LoadTreeByID(id)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Msg = model.Conf.Language(56)
|
||||
|
|
@ -438,11 +438,11 @@ func getBlockInfo(c *gin.Context) {
|
|||
}
|
||||
|
||||
root, err := model.GetBlock(block.RootID, tree)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = model.Conf.Language(56)
|
||||
|
|
|
|||
|
|
@ -61,13 +61,7 @@ func appendBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -106,13 +100,7 @@ func prependBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -169,13 +157,7 @@ func insertBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -260,13 +242,7 @@ func updateBlock(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
err = model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -298,12 +274,7 @@ func deleteBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
model.PerformTransactions(&transactions)
|
||||
|
||||
ret.Data = transactions
|
||||
broadcastTransactions(transactions)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
|
|
@ -27,7 +26,6 @@ import (
|
|||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -691,11 +689,11 @@ func getDoc(c *gin.Context) {
|
|||
}
|
||||
|
||||
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if model.ErrBlockNotFound == err {
|
||||
ret.Code = 3
|
||||
return
|
||||
|
|
|
|||
|
|
@ -17,14 +17,12 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
|
@ -61,10 +59,7 @@ func performTransactions(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = model.PerformTransactions(&transactions); errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 1
|
||||
return
|
||||
}
|
||||
model.PerformTransactions(&transactions)
|
||||
|
||||
ret.Data = transactions
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erro
|
|||
data, err := filelock.ReadFile(filePath)
|
||||
if nil != err {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", p, err)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -96,10 +92,6 @@ func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *p
|
|||
}
|
||||
} else {
|
||||
logging.LogWarnf("read parent tree data [%s] failed: %s", parentAbsPath, readErr)
|
||||
if errors.Is(readErr, filelock.ErrUnableAccessFile) {
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
return
|
||||
}
|
||||
}
|
||||
hPathBuilder.WriteString("Untitled/")
|
||||
continue
|
||||
|
|
@ -129,10 +121,6 @@ func WriteTreeWithoutChangeTime(tree *parse.Tree) (err error) {
|
|||
}
|
||||
|
||||
if err = filelock.WriteFileWithoutChangeTime(filePath, data); nil != err {
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("write data [%s] failed: %s", filePath, err)
|
||||
logging.LogErrorf(msg)
|
||||
return errors.New(msg)
|
||||
|
|
@ -149,10 +137,6 @@ func WriteTree(tree *parse.Tree) (err error) {
|
|||
}
|
||||
|
||||
if err = filelock.WriteFile(filePath, data); nil != err {
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("write data [%s] failed: %s", filePath, err)
|
||||
logging.LogErrorf(msg)
|
||||
return errors.New(msg)
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ require (
|
|||
github.com/siyuan-note/dejavu v0.0.0-20230315034343-e9513a7e1999
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
|
||||
github.com/siyuan-note/filelock v0.0.0-20230318101209-f0e353df8b5b
|
||||
github.com/siyuan-note/filelock v0.0.0-20230319015503-9ac4a0ee675b
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc
|
||||
github.com/siyuan-note/logging v0.0.0-20230318100514-8ece27db458d
|
||||
github.com/siyuan-note/logging v0.0.0-20230319012246-6224f958f554
|
||||
github.com/siyuan-note/riff v0.0.0-20230224144841-cfbe0748ddb7
|
||||
github.com/steambap/captcha v1.4.1
|
||||
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2
|
||||
|
|
@ -126,7 +126,6 @@ require (
|
|||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
go.uber.org/multierr v1.10.0 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.7.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230314191032-db074128a8ec // indirect
|
||||
|
|
|
|||
|
|
@ -283,12 +283,12 @@ github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29
|
|||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b h1:828lTUW2C0uNiolODqoACu7J8sDUzswD4Xo04mUombg=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
|
||||
github.com/siyuan-note/filelock v0.0.0-20230318101209-f0e353df8b5b h1:NtC1PhGKtOvjQNf95UUW3K5OW/0OIu3ny8sLq9YYqOQ=
|
||||
github.com/siyuan-note/filelock v0.0.0-20230318101209-f0e353df8b5b/go.mod h1:kL4KLZ3/SJxQFQ/lUxkbOyQiqVh/MJyo1CGy6sAUqM8=
|
||||
github.com/siyuan-note/filelock v0.0.0-20230319015503-9ac4a0ee675b h1:nK+77PDzDEyLBAdX4e3SKWQp6P1uDP0Td8j72ir1hT0=
|
||||
github.com/siyuan-note/filelock v0.0.0-20230319015503-9ac4a0ee675b/go.mod h1:sOq/g1jqdnkR/kAqOsTZFSr10Env4AN2nKOhZn62vQ8=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc h1:MX2cPWpn7Hfd3FmpwLjGdPIjF84AFUS9f/mcPJc/4w4=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20230309131049-f703795de6bc/go.mod h1:WDO42mUVRnkk8M4AhZ4oakZ5jnghulP0c8NFCrrFWG4=
|
||||
github.com/siyuan-note/logging v0.0.0-20230318100514-8ece27db458d h1:K7y9mEvoQ2PZkM0f+bHvnyDi/gnKfY5OJjYUe2GFnpc=
|
||||
github.com/siyuan-note/logging v0.0.0-20230318100514-8ece27db458d/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
|
||||
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/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/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
|
|
@ -338,8 +338,6 @@ github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
|
|||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
||||
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
|
||||
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
|
|
|
|||
|
|
@ -211,7 +211,9 @@ func (box *Box) saveConf0(data []byte) {
|
|||
logging.LogErrorf("save box conf [%s] failed: %s", confPath, err)
|
||||
}
|
||||
if err := filelock.WriteFile(confPath, data); nil != err {
|
||||
logging.LogErrorf("save box conf [%s] failed: %s", confPath, err)
|
||||
logging.LogErrorf("write box conf [%s] failed: %s", confPath, err)
|
||||
util.ReportFileSysFatalError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -896,10 +896,7 @@ func DuplicateDoc(tree *parse.Tree) {
|
|||
|
||||
func createTreeTx(tree *parse.Tree) {
|
||||
transaction := &Transaction{DoOperations: []*Operation{{Action: "create", Data: tree}}}
|
||||
err := PerformTransactions(&[]*Transaction{transaction})
|
||||
if nil != err {
|
||||
logging.LogFatalf("transaction failed: %s", err)
|
||||
}
|
||||
PerformTransactions(&[]*Transaction{transaction})
|
||||
}
|
||||
|
||||
func CreateDocByMd(boxID, p, title, md string, sorts []string) (tree *parse.Tree, err error) {
|
||||
|
|
@ -1450,11 +1447,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
|
|||
}
|
||||
|
||||
transaction := &Transaction{DoOperations: []*Operation{{Action: "create", Data: tree}}}
|
||||
err = PerformTransactions(&[]*Transaction{transaction})
|
||||
if nil != err {
|
||||
logging.LogFatalf("transaction failed: %s", err)
|
||||
return
|
||||
}
|
||||
PerformTransactions(&[]*Transaction{transaction})
|
||||
WaitForWritingFiles()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,10 +259,6 @@ func setCriteria(criteria []*Criterion) (err error) {
|
|||
err = filelock.WriteFile(lsPath, data)
|
||||
if nil != err {
|
||||
logging.LogErrorf("write storage [criteria] failed: %s", err)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
|
|
@ -278,10 +274,6 @@ func getCriteria() (ret []*Criterion, err error) {
|
|||
data, err := filelock.ReadFile(dataPath)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read storage [criteria] failed: %s", err)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -353,10 +345,6 @@ func setLocalStorage(val interface{}) (err error) {
|
|||
err = filelock.WriteFile(lsPath, data)
|
||||
if nil != err {
|
||||
logging.LogErrorf("write storage [local] failed: %s", err)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
|
|
@ -372,10 +360,6 @@ func getLocalStorage() (ret map[string]interface{}, err error) {
|
|||
data, err := filelock.ReadFile(lsPath)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read storage [local] failed: %s", err)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
os.Exit(logging.ExitCodeFileSysInconsistent)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package model
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -107,11 +106,8 @@ func flushTx() {
|
|||
case TxErrCodeBlockNotFound:
|
||||
util.PushTxErr("Transaction failed", txErr.code, nil)
|
||||
return
|
||||
case TxErrCodeUnableAccessFile:
|
||||
util.PushTxErr(Conf.Language(76), txErr.code, txErr.id)
|
||||
return
|
||||
default:
|
||||
logging.LogFatalf("transaction failed: %s", txErr.msg)
|
||||
logging.LogFatalf(logging.ExitCodeFatal, "transaction failed: %s", txErr.msg)
|
||||
}
|
||||
}
|
||||
elapsed := time.Now().Sub(start).Milliseconds()
|
||||
|
|
@ -150,7 +146,7 @@ func mergeTx() (ret *Transaction) {
|
|||
return
|
||||
}
|
||||
|
||||
func PerformTransactions(transactions *[]*Transaction) (err error) {
|
||||
func PerformTransactions(transactions *[]*Transaction) {
|
||||
txQueueLock.Lock()
|
||||
txQueue = append(txQueue, *transactions...)
|
||||
txQueueLock.Unlock()
|
||||
|
|
@ -158,10 +154,9 @@ func PerformTransactions(transactions *[]*Transaction) (err error) {
|
|||
}
|
||||
|
||||
const (
|
||||
TxErrCodeBlockNotFound = 0
|
||||
TxErrCodeUnableAccessFile = 1
|
||||
TxErrCodeWriteTree = 2
|
||||
TxErrWriteAttributeView = 3
|
||||
TxErrCodeBlockNotFound = 0
|
||||
TxErrCodeWriteTree = 2
|
||||
TxErrWriteAttributeView = 3
|
||||
)
|
||||
|
||||
type TxErr struct {
|
||||
|
|
@ -231,10 +226,6 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
}
|
||||
|
||||
if cr := tx.commit(); nil != cr {
|
||||
if errors.Is(cr, filelock.ErrUnableAccessFile) {
|
||||
return &TxErr{code: TxErrCodeUnableAccessFile, msg: cr.Error()}
|
||||
}
|
||||
|
||||
logging.LogErrorf("commit tx failed: %s", cr)
|
||||
return &TxErr{msg: cr.Error()}
|
||||
}
|
||||
|
|
@ -420,9 +411,6 @@ func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: operation.ParentID}
|
||||
}
|
||||
tree, err := tx.loadTree(block.ID)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return &TxErr{code: TxErrCodeUnableAccessFile, msg: err.Error(), id: block.ID}
|
||||
}
|
||||
if nil != err {
|
||||
msg := fmt.Sprintf("load tree [%s] failed: %s", block.ID, err)
|
||||
logging.LogErrorf(msg)
|
||||
|
|
@ -507,9 +495,6 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: operation.ParentID}
|
||||
}
|
||||
tree, err := tx.loadTree(block.ID)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return &TxErr{code: TxErrCodeUnableAccessFile, msg: err.Error(), id: block.ID}
|
||||
}
|
||||
if nil != err {
|
||||
msg := fmt.Sprintf("load tree [%s] failed: %s", block.ID, err)
|
||||
logging.LogErrorf(msg)
|
||||
|
|
@ -664,9 +649,6 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
|
|||
var err error
|
||||
id := operation.ID
|
||||
tree, err := tx.loadTree(id)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return &TxErr{code: TxErrCodeUnableAccessFile, msg: err.Error(), id: id}
|
||||
}
|
||||
if ErrBlockNotFound == err {
|
||||
return nil // move 以后这里会空,算作正常情况
|
||||
}
|
||||
|
|
@ -719,9 +701,6 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
|
||||
tree, err := tx.loadTree(block.ID)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return &TxErr{code: TxErrCodeUnableAccessFile, msg: err.Error(), id: block.ID}
|
||||
}
|
||||
if nil != err {
|
||||
msg := fmt.Sprintf("load tree [%s] failed: %s", block.ID, err)
|
||||
logging.LogErrorf(msg)
|
||||
|
|
@ -864,9 +843,6 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||
id := operation.ID
|
||||
|
||||
tree, err := tx.loadTree(id)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
return &TxErr{code: TxErrCodeUnableAccessFile, msg: err.Error(), id: id}
|
||||
}
|
||||
if nil != err {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", id, err)
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
||||
|
|
|
|||
|
|
@ -112,84 +112,84 @@ func InitDatabase(forceRebuild bool) (err error) {
|
|||
func initDBTables() {
|
||||
_, err := db.Exec("DROP TABLE IF EXISTS stat")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [stat] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [stat] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE stat (key, value)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [stat] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [stat] failed: %s", err)
|
||||
}
|
||||
setDatabaseVer()
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS blocks")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [blocks] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [blocks] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE blocks (id, parent_id, root_id, hash, box, path, hpath, name, alias, memo, tag, content, fcontent, markdown, length, type, subtype, ial, sort, created, updated)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [blocks] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [blocks] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS blocks_fts")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [blocks_fts] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [blocks_fts] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE VIRTUAL TABLE blocks_fts USING fts5(id UNINDEXED, parent_id UNINDEXED, root_id UNINDEXED, hash UNINDEXED, box UNINDEXED, path UNINDEXED, hpath, name, alias, memo, tag, content, fcontent, markdown UNINDEXED, length UNINDEXED, type UNINDEXED, subtype UNINDEXED, ial, sort UNINDEXED, created UNINDEXED, updated UNINDEXED, tokenize=\"siyuan\")")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [blocks_fts] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [blocks_fts] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS blocks_fts_case_insensitive")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [blocks_fts_case_insensitive] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [blocks_fts_case_insensitive] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE VIRTUAL TABLE blocks_fts_case_insensitive USING fts5(id UNINDEXED, parent_id UNINDEXED, root_id UNINDEXED, hash UNINDEXED, box UNINDEXED, path UNINDEXED, hpath, name, alias, memo, tag, content, fcontent, markdown UNINDEXED, length UNINDEXED, type UNINDEXED, subtype UNINDEXED, ial, sort UNINDEXED, created UNINDEXED, updated UNINDEXED, tokenize=\"siyuan case_insensitive\")")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [blocks_fts_case_insensitive] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [blocks_fts_case_insensitive] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS spans")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [spans] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [spans] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE spans (id, block_id, root_id, box, path, content, markdown, type, ial)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [spans] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [spans] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS assets")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [assets] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [assets] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE assets (id, block_id, root_id, box, docpath, path, name, title, hash)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [assets] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [assets] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS attributes")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [attributes] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [attributes] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE attributes (id, name, value, type, block_id, root_id, box, path)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [attributes] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [attributes] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS refs")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [refs] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [refs] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE refs (id, def_block_id, def_block_parent_id, def_block_root_id, def_block_path, block_id, root_id, box, path, content, markdown, type)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [refs] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [refs] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS file_annotation_refs")
|
||||
if nil != err {
|
||||
logging.LogFatalf("drop table [refs] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [refs] failed: %s", err)
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE file_annotation_refs (id, file_path, annotation_id, block_id, root_id, box, path, content, type)")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [refs] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [refs] failed: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ func initHistoryDBConnection() {
|
|||
var err error
|
||||
historyDB, err = sql.Open("sqlite3_extended", dsn)
|
||||
if nil != err {
|
||||
logging.LogFatalf("create database failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create database failed: %s", err)
|
||||
}
|
||||
historyDB.SetMaxIdleConns(3)
|
||||
historyDB.SetMaxOpenConns(3)
|
||||
|
|
@ -239,7 +239,7 @@ func initHistoryDBTables() {
|
|||
historyDB.Exec("DROP TABLE histories_fts_case_insensitive")
|
||||
_, err := historyDB.Exec("CREATE VIRTUAL TABLE histories_fts_case_insensitive USING fts5(type UNINDEXED, op UNINDEXED, title, content, path UNINDEXED, created UNINDEXED, tokenize=\"siyuan case_insensitive\")")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [histories_fts_case_insensitive] failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [histories_fts_case_insensitive] failed: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ func initDBConnection() {
|
|||
var err error
|
||||
db, err = sql.Open("sqlite3_extended", dsn)
|
||||
if nil != err {
|
||||
logging.LogFatalf("create database failed: %s", err)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create database failed: %s", err)
|
||||
}
|
||||
db.SetMaxIdleConns(20)
|
||||
db.SetMaxOpenConns(20)
|
||||
|
|
@ -1206,7 +1206,7 @@ func execStmtTx(tx *sql.Tx, stmt string, args ...interface{}) (err error) {
|
|||
tx.Rollback()
|
||||
closeDatabase()
|
||||
removeDatabaseFile()
|
||||
logging.LogFatalf("database disk image [%s] is malformed, please restart SiYuan kernel to rebuild it", util.DBPath)
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "database disk image [%s] is malformed, please restart SiYuan kernel to rebuild it", util.DBPath)
|
||||
}
|
||||
logging.LogErrorf("exec database stmt [%s] failed: %s\n %s", stmt, err, logging.ShortStack())
|
||||
return
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ func InitBlockTree(force bool) {
|
|||
entries, err := os.ReadDir(util.BlockTreePath)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read block tree dir failed: %s", err)
|
||||
os.Exit(logging.ExitCodeBlockTreeErr)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +342,7 @@ func InitBlockTree(force bool) {
|
|||
fh, err = os.OpenFile(p, os.O_RDWR, 0644)
|
||||
if nil != err {
|
||||
logging.LogErrorf("open block tree file failed: %s", err)
|
||||
os.Exit(logging.ExitCodeBlockTreeErr)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ func InitBlockTree(force bool) {
|
|||
fh.Close()
|
||||
if nil != err {
|
||||
logging.LogErrorf("read block tree failed: %s", err)
|
||||
os.Exit(logging.ExitCodeBlockTreeErr)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ func InitBlockTree(force bool) {
|
|||
if err = os.RemoveAll(util.BlockTreePath); nil != err {
|
||||
logging.LogErrorf("removed corrupted block tree failed: %s", err)
|
||||
}
|
||||
os.Exit(logging.ExitCodeBlockTreeErr)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ func SaveBlockTree(force bool) {
|
|||
data, err := msgpack.Marshal(slice.data)
|
||||
if nil != err {
|
||||
logging.LogErrorf("marshal block tree failed: %s", err)
|
||||
os.Exit(logging.ExitCodeBlockTreeErr)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
return false
|
||||
}
|
||||
slice.m.Unlock()
|
||||
|
|
@ -418,7 +418,7 @@ func SaveBlockTree(force bool) {
|
|||
p := filepath.Join(util.BlockTreePath, key.(string)) + ".msgpack"
|
||||
if err = gulu.File.WriteFileSafer(p, data, 0644); nil != err {
|
||||
logging.LogErrorf("write block tree failed: %s", err)
|
||||
os.Exit(logging.ExitCodeBlockTreeErr)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ func FormatNode(node *ast.Node, luteEngine *lute.Lute) string {
|
|||
markdown, err := lute.FormatNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
if nil != err {
|
||||
root := TreeRoot(node)
|
||||
logging.LogFatalf("format node [%s] in tree [%s] failed: %s", node.ID, root.ID, err)
|
||||
logging.LogFatalf(logging.ExitCodeFatal, "format node [%s] in tree [%s] failed: %s", node.ID, root.ID, err)
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {
|
|||
markdown, err := lute.ProtyleExportMdNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
if nil != err {
|
||||
root := TreeRoot(node)
|
||||
logging.LogFatalf("export markdown for node [%s] in tree [%s] failed: %s", node.ID, root.ID, err)
|
||||
logging.LogFatalf(logging.ExitCodeFatal, "export markdown for node [%s] in tree [%s] failed: %s", node.ID, root.ID, err)
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,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(logging.ExitCodeFileSysInconsistent)
|
||||
os.Exit(logging.ExitCodeFileSysErr)
|
||||
}
|
||||
|
||||
func CheckFileSysStatus() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue