mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 01:22:02 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
a1c81fda03
@ -550,7 +550,7 @@ const initKernel = (initData) => {
|
|||||||
switch (code) {
|
switch (code) {
|
||||||
case 20:
|
case 20:
|
||||||
showErrorWindow('⚠️ 数据库被锁定 The database is locked',
|
showErrorWindow('⚠️ 数据库被锁定 The database is locked',
|
||||||
`<div>数据库文件正在被其他进程占用,请检查是否同时存在多个内核进程(SiYuan Kernel)。</div><div>The database file is being occupied by other processes, please check whether there are multiple kernel processes (SiYuan Kernel) at the same time.</div>`)
|
`<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
|
break
|
||||||
case 21:
|
case 21:
|
||||||
showErrorWindow('⚠️ 监听端口 ' + kernelPort + ' 失败 Failed to listen to port ' + kernelPort,
|
showErrorWindow('⚠️ 监听端口 ' + kernelPort + ' 失败 Failed to listen to port ' + kernelPort,
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {dialog} from "@electron/remote";
|
import {dialog} from "@electron/remote";
|
||||||
import {SaveDialogReturnValue, shell} from "electron";
|
import {shell} from "electron";
|
||||||
import {afterExport} from "../protyle/export/util";
|
import {afterExport} from "../protyle/export/util";
|
||||||
|
import * as path from "path";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isBrowser} from "../util/functions";
|
import {isBrowser} from "../util/functions";
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
@ -157,19 +158,20 @@ export const exportConfig = {
|
|||||||
window.location.href = response.data.zip;
|
window.location.href = response.data.zip;
|
||||||
});
|
});
|
||||||
/// #else
|
/// #else
|
||||||
dialog.showSaveDialog({
|
let filePaths = dialog.showOpenDialogSync({
|
||||||
defaultPath: "data",
|
title: window.siyuan.languages.export + " " + "Data",
|
||||||
properties: ["showOverwriteConfirmation"],
|
properties: ["createDirectory", "openDirectory"],
|
||||||
}).then((result: SaveDialogReturnValue) => {
|
})
|
||||||
if (!result.canceled) {
|
if (filePaths && 0 < filePaths.length) {
|
||||||
|
const savePath = filePaths[0];
|
||||||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
||||||
fetchPost("/api/export/exportDataInFolder", {
|
fetchPost("/api/export/exportDataInFolder", {
|
||||||
folder: result.filePath
|
folder: savePath,
|
||||||
}, () => {
|
}, response => {
|
||||||
afterExport(result.filePath, msgId);
|
afterExport(path.join(savePath, response.data.name), msgId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
/// #endif
|
/// #endif
|
||||||
});
|
});
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
|
@ -41,13 +41,16 @@ func exportDataInFolder(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportFolder := arg["folder"].(string)
|
exportFolder := arg["folder"].(string)
|
||||||
err := model.ExportDataInFolder(exportFolder)
|
name, err := model.ExportDataInFolder(exportFolder)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"name": name,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportData(c *gin.Context) {
|
func exportData(c *gin.Context) {
|
||||||
|
@ -530,7 +530,7 @@ func FullReindex() {
|
|||||||
WaitForWritingFiles()
|
WaitForWritingFiles()
|
||||||
|
|
||||||
if err := sql.InitDatabase(true); nil != err {
|
if err := sql.InitDatabase(true); nil != err {
|
||||||
util.PushErrMsg(fmt.Sprintf(Conf.Language(85), err), 5000)
|
os.Exit(util.ExitCodeReadOnlyDatabase)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
treenode.InitBlockTree(true)
|
treenode.InitBlockTree(true)
|
||||||
|
@ -120,17 +120,18 @@ func ExportSY(id string) (name, zipPath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExportDataInFolder(exportFolder string) (err error) {
|
func ExportDataInFolder(exportFolder string) (name string, err error) {
|
||||||
util.PushEndlessProgress(Conf.Language(65))
|
util.PushEndlessProgress(Conf.Language(65))
|
||||||
defer util.ClearPushProgress(100)
|
defer util.ClearPushProgress(100)
|
||||||
|
|
||||||
WaitForWritingFiles()
|
WaitForWritingFiles()
|
||||||
|
|
||||||
exportFolder = filepath.Join(exportFolder, util.CurrentTimeSecondsStr())
|
exportFolder = filepath.Join(exportFolder, util.CurrentTimeSecondsStr())
|
||||||
err = exportData(exportFolder)
|
zipPath, err := exportData(exportFolder)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
name = filepath.Base(zipPath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,10 +141,8 @@ func ExportData() (zipPath string) {
|
|||||||
|
|
||||||
WaitForWritingFiles()
|
WaitForWritingFiles()
|
||||||
|
|
||||||
baseFolderName := "data-" + util.CurrentTimeSecondsStr()
|
exportFolder := filepath.Join(util.TempDir, "export", util.CurrentTimeSecondsStr())
|
||||||
exportFolder := filepath.Join(util.TempDir, "export", baseFolderName)
|
zipPath, err := exportData(exportFolder)
|
||||||
zipPath = exportFolder + ".zip"
|
|
||||||
err := exportData(exportFolder)
|
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -151,7 +150,7 @@ func ExportData() (zipPath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportData(exportFolder string) (err error) {
|
func exportData(exportFolder string) (zipPath string, err error) {
|
||||||
baseFolderName := "data-" + util.CurrentTimeSecondsStr()
|
baseFolderName := "data-" + util.CurrentTimeSecondsStr()
|
||||||
if err = os.MkdirAll(exportFolder, 0755); nil != err {
|
if err = os.MkdirAll(exportFolder, 0755); nil != err {
|
||||||
logging.LogErrorf("create export temp folder failed: %s", err)
|
logging.LogErrorf("create export temp folder failed: %s", err)
|
||||||
@ -165,7 +164,7 @@ func exportData(exportFolder string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
zipPath := exportFolder + ".zip"
|
zipPath = exportFolder + ".zip"
|
||||||
zip, err := gulu.Zip.Create(zipPath)
|
zip, err := gulu.Zip.Create(zipPath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogErrorf("create export data zip [%s] failed: %s", exportFolder, err)
|
logging.LogErrorf("create export data zip [%s] failed: %s", exportFolder, err)
|
||||||
|
@ -118,9 +118,9 @@ func Serve(fastMode bool) {
|
|||||||
// 启动一个 6806 端口的反向代理服务器,这样浏览器扩展才能直接使用 127.0.0.1:6806,不用配置端口
|
// 启动一个 6806 端口的反向代理服务器,这样浏览器扩展才能直接使用 127.0.0.1:6806,不用配置端口
|
||||||
serverURL, _ := url.Parse("http://" + host + ":" + port)
|
serverURL, _ := url.Parse("http://" + host + ":" + port)
|
||||||
proxy := httputil.NewSingleHostReverseProxy(serverURL)
|
proxy := httputil.NewSingleHostReverseProxy(serverURL)
|
||||||
logging.LogInfof("kernel reverse proxy server [%s] is booting", util.FixedPort)
|
logging.LogInfof("reverse proxy server [%s] is booting", util.FixedPort)
|
||||||
if proxyErr := http.ListenAndServe(host+":"+util.FixedPort, proxy); nil != proxyErr {
|
if proxyErr := http.ListenAndServe(host+":"+util.FixedPort, proxy); nil != proxyErr {
|
||||||
logging.LogErrorf("boot kernel reverse proxy server [%s] failed: %s", serverURL, proxyErr)
|
logging.LogWarnf("boot reverse proxy server [%s] failed: %s", serverURL, proxyErr)
|
||||||
}
|
}
|
||||||
// 反代服务器启动失败不影响核心服务器启动
|
// 反代服务器启动失败不影响核心服务器启动
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user