Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Data snapshot save device ID, name and OS https://github.com/siyuan-note/siyuan/issues/8094

Liang Ding051ddf74ae9f
diff --git a/app/src/history/history.ts b/app/src/history/history.ts
index 1f609d3cf3..8c8184ace5 100644
--- a/app/src/history/history.ts
+++ b/app/src/history/history.ts
@@ -161,6 +161,9 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
hCreated: string,
count: number,
hSize: string,
+ systemID: string,
+ systemName: string,
+ systemOS: string,
tag: string,
typesCount: { type: string, count: number }[]
}) => {
@@ -178,13 +181,15 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
<span class="b3-chip b3-chip--secondary b3-chip--small${item.tag ? "" : " fn__none"}">${item.tag}</span>
</div>
<div class="b3-list-item__meta">
- <code class="fn__code">${item.id.substring(0, 7)}</code>
+ <code class="fn__code">${item.id.substring(0, 7)}</code>
<span class="fn__space"></span>
<span data-type="hCreated">${item.hCreated}</span>
<span class="fn__space"></span>
${item.hSize}
<span class="fn__space"></span>
${window.siyuan.languages.fileCount} ${item.count}
+ <span class="fn__space"></span>
+ ${item.systemOS}/${item.systemName}
</div>
${statHTML}`;
/// #if MOBILE
diff --git a/kernel/conf/system.go b/kernel/conf/system.go
index b3bdffc373..917cfaa6cb 100644
--- a/kernel/conf/system.go
+++ b/kernel/conf/system.go
@@ -22,6 +22,7 @@ import (
type System struct {
ID string `json:"id"`
+ Name string `json:"name"`
KernelVersion string `json:"kernelVersion"`
OS string `json:"os"`
OSPlatform string `json:"osPlatform"`
@@ -47,6 +48,7 @@ type System struct {
func NewSystem() *System {
return &System{
ID: util.GetDeviceID(),
+ Name: util.GetDeviceName(),
KernelVersion: util.Ver,
NetworkProxy: &NetworkProxy{},
DownloadInstallPkg: true,
diff --git a/kernel/go.mod b/kernel/go.mod
index 70a5f808c9..88abbb676f 100644
--- a/kernel/go.mod
+++ b/kernel/go.mod
@@ -44,7 +44,7 @@ require (
github.com/radovskyb/watcher v1.0.7
github.com/sashabaranov/go-gpt3 v1.4.0
github.com/shirou/gopsutil/v3 v3.23.2
- github.com/siyuan-note/dejavu v0.0.0-20230421144748-43d79a87c9f9
+ github.com/siyuan-note/dejavu v0.0.0-20230424035816-c47703a13fd4
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-20230417044524-125ee78b5cc9
diff --git a/kernel/go.sum b/kernel/go.sum
index a4c3eb5700..9a606fd2f9 100644
--- a/kernel/go.sum
+++ b/kernel/go.sum
@@ -277,8 +277,10 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
-github.com/siyuan-note/dejavu v0.0.0-20230421144748-43d79a87c9f9 h1:vOGSTlJpei7tyVOpgwSXVChmf65NHkuL9GvMWPjfPgo=
-github.com/siyuan-note/dejavu v0.0.0-20230421144748-43d79a87c9f9/go.mod h1:R3PnH4Y9/0TollG4g0tX7jGW7lvhNIEL9hYi5zQ4+sI=
+github.com/siyuan-note/dejavu v0.0.0-20230424034810-63afce096499 h1:2cAa1Y8GG1f13cyy1g1SLWHty/EYaj02EMza2ql3FTs=
+github.com/siyuan-note/dejavu v0.0.0-20230424034810-63afce096499/go.mod h1:R3PnH4Y9/0TollG4g0tX7jGW7lvhNIEL9hYi5zQ4+sI=
+github.com/siyuan-note/dejavu v0.0.0-20230424035816-c47703a13fd4 h1:5hkMgzn1kyrBVK0BQTSh6jrCMrNDBKoJD/tR7U+4Tqc=
+github.com/siyuan-note/dejavu v0.0.0-20230424035816-c47703a13fd4/go.mod h1:R3PnH4Y9/0TollG4g0tX7jGW7lvhNIEL9hYi5zQ4+sI=
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
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=
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index 904f5ca2b1..f1a10af129 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -235,8 +235,12 @@ func InitConf() {
if "" == Conf.System.ID {
Conf.System.ID = util.GetDeviceID()
}
+ if "" == Conf.System.Name {
+ Conf.System.Name = util.GetDeviceName()
+ }
if util.ContainerStd == util.Container {
Conf.System.ID = util.GetDeviceID()
+ Conf.System.Name = util.GetDeviceName()
}
Conf.System.AppDir = util.WorkingDir
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index 5623197a03..62a6c0a8c2 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -1401,7 +1401,7 @@ func newRepository() (ret *dejavu.Repo, err error) {
ignoreLines := getIgnoreLines()
ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置
- ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.System.ID, Conf.Repo.Key, ignoreLines, cloudRepo)
+ ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.System.ID, Conf.System.Name, Conf.System.OS, Conf.Repo.Key, ignoreLines, cloudRepo)
if nil != err {
logging.LogErrorf("init data repo failed: %s", err)
return
diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go
index 596bf68104..d6272adfd0 100644
--- a/kernel/util/runtime.go
+++ b/kernel/util/runtime.go
@@ -83,6 +83,14 @@ func GetDeviceID() string {
return gulu.Rand.String(12)
}
+func GetDeviceName() string {
+ ret, err := os.Hostname()
+ if nil != err {
+ return "unknown"
+ }
+ return ret
+}
+
func SetNetworkProxy(proxyURL string) {
if err := os.Setenv("HTTPS_PROXY", proxyURL); nil != err {
logging.LogErrorf("set env [HTTPS_PROXY] failed: %s", err)