Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-06-14 19:23:57 +08:00
commit 44e43d620a
10 changed files with 59 additions and 30 deletions

View file

@ -768,7 +768,7 @@
"23": "Backup failed: %s",
"24": "Failed to obtain cloud sync info: %s",
"25": "The attribute name only supports English letters and digits",
"26": "Generate auth key failed",
"26": "Please initialize the data repo key first in [Settings - About - Data repo key]",
"27": "Data integrity check failed",
"28": "Incorrect end-to-end encryption password, unable to decrypt data",
"29": "This feature requires <a target='_blank' href='https://ld246.com/subscribe/siyuan'>paid subscription</a> (If you have subscribed, please refresh or log in again in settings - account)",

View file

@ -768,7 +768,7 @@
"23": "La sauvegarde a échoué : %s",
"24": "Impossible d'obtenir les informations de synchronisation du Cloud : %s",
"25": "Le nom de l'attribut ne supporte que les lettres et les chiffres anglais.",
"26": "La génération de la clé d'authentification a échoué",
"26": "Veuillez d'abord initialiser la clé du référentiel de données dans [Paramètres - À propos - Clé du référentiel de données]",
"27": "La vérification de l'intégrité des données a échoué",
"28": "Mot de passe de cryptage de bout en bout incorrect, impossible de décrypter les données",
"29": "Cette fonctionnalité nécessite <a target='_blank' href='https://ld246.com/subscribe/siyuan'>un abonnement payant</a> (Si vous êtes déjà abonné, Rafraîchissez ou connectez - vous à nouveau dans Paramètres - compte)",

View file

@ -768,7 +768,7 @@
"23": "備份失敗:%s",
"24": "獲取雲端同步資訊失敗:%s",
"25": "屬性名僅支援英文字母和阿拉伯數字",
"26": "生成認證金鑰失敗",
"26": "請先在 [設置 - 關於 - 數據倉庫密鑰] 中初始化數據倉庫密鑰",
"27": "數據完整性校驗失敗",
"28": "端到端加密密碼不正確,無法解密數據",
"29": "該功能需要<a target='_blank' href='https://ld246.com/subscribe/siyuan'>付費訂閱</a>(如果你已經訂閱,請在設定-帳號中重繪或者重新登入)",

View file

@ -769,7 +769,7 @@
"23": "备份失败:%s",
"24": "获取云端同步信息失败:%s",
"25": "属性名仅支持英文字母和阿拉伯数字",
"26": "生成认证密钥失败",
"26": "请先在 [设置 - 关于 - 数据仓库密钥] 中初始化数据仓库密钥",
"27": "数据完整性校验失败",
"28": "端到端加密密码不正确,无法解密数据",
"29": "该功能需要<a target='_blank' href='https://ld246.com/subscribe/siyuan'>付费订阅</a>(如果你已经订阅,请在 设置 - 账号中刷新或者重新登录)",

View file

@ -55,14 +55,16 @@ func getRepoIndexLogs(c *gin.Context) {
}
page := arg["page"].(float64)
logs, err := model.GetRepoIndexLogs(int(page))
logs, pageCount, totalCount, err := model.GetRepoIndexLogs(int(page))
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
ret.Data = map[string]interface{}{
"logs": logs,
"logs": logs,
"pageCount": pageCount,
"totalCount": totalCount,
}
}

View file

@ -40,7 +40,7 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/qiniu/go-sdk/v7 v7.13.0
github.com/radovskyb/watcher v1.0.7
github.com/siyuan-note/dejavu v0.0.0-20220613154907-7c4058d9f1e1
github.com/siyuan-note/dejavu v0.0.0-20220614100921-f1d318f3dd6b
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676
github.com/vmihailenco/msgpack/v5 v5.3.5
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
@ -106,6 +106,7 @@ require (
replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20220412041952-88c3aaa8595e
//replace github.com/siyuan-note/dejavu => D:\88250\dejavu
//replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute
//replace github.com/88250/enumfonts => D:\88250\enumfonts
//replace github.com/88250/pdfcpu => D:\88250\pdfcpu

View file

@ -419,8 +419,8 @@ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJ
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/siyuan-note/dejavu v0.0.0-20220613154907-7c4058d9f1e1 h1:Z0Q4sjonCyTc0SHor86LM+oP6DM8wL6Xx+BKtReees4=
github.com/siyuan-note/dejavu v0.0.0-20220613154907-7c4058d9f1e1/go.mod h1:Oa/Y6fvTUCg8h9/t6GNWXiu8T7aQri/ZvyDRygnlikI=
github.com/siyuan-note/dejavu v0.0.0-20220614100921-f1d318f3dd6b h1:GyLlhQQsgfVFzyWB+OB1wCRlyzBhI4EkczC0YK9cRHc=
github.com/siyuan-note/dejavu v0.0.0-20220614100921-f1d318f3dd6b/go.mod h1:Oa/Y6fvTUCg8h9/t6GNWXiu8T7aQri/ZvyDRygnlikI=
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676 h1:QB9TjJQFhXhZ6dAtPpY02DlzHAQm1C+WqZq6OadG8mI=
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=

View file

@ -550,7 +550,11 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
ret = append(ret, dest)
} else {
if ast.NodeWidget == n.Type {
dataAssets := n.IALAttr("data-assets")
dataAssets := n.IALAttr("custom-data-assets")
if "" == dataAssets {
// 兼容两种属性名 custom-data-assets 和 data-assets https://github.com/siyuan-note/siyuan/issues/4122#issuecomment-1154796568
dataAssets = n.IALAttr("data-assets")
}
if "" == dataAssets || !isRelativePath([]byte(dataAssets)) {
return ast.WalkContinue
}

View file

@ -21,6 +21,7 @@ import (
"encoding/hex"
"errors"
"os"
"time"
"github.com/88250/gulu"
"github.com/siyuan-note/dejavu"
@ -30,17 +31,12 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func GetRepoFile(id string) (ret []byte, err error) {
//repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
//if nil != err {
// util.LogErrorf("init repo failed: %s", err)
// return
//}
func GetRepoIndexLogs(page int) (logs []*dejavu.Log, pageCount, totalCount int, err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
return
}
return
}
func GetRepoIndexLogs(page int) (logs []*dejavu.Log, err error) {
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
if nil != err {
util.LogErrorf("init repo failed: %s", err)
@ -48,8 +44,14 @@ func GetRepoIndexLogs(page int) (logs []*dejavu.Log, err error) {
}
page-- // 从 0 开始
logs, err = repo.GetIndexLogs(page, 32)
logs, pageCount, totalCount, err = repo.GetIndexLogs(page, 32)
if nil != err {
if dejavu.ErrNotFoundIndex == err {
logs = []*dejavu.Log{}
err = nil
return
}
util.LogErrorf("get repo index logs failed: %s", err)
return
}
@ -113,13 +115,13 @@ var checkoutCallbacks = map[string]dejavu.Callback{
context.(func(msg string))(arg.(*entity.File).Path)
},
"removeFile": func(context, arg interface{}, err error) {
context.(func(msg string))(arg.(*entity.File).Path)
context.(func(msg string))(arg.(string))
},
}
func CheckoutRepo(id string) (err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New("repo key is nil")
err = errors.New(Conf.Language(26))
return
}
@ -129,11 +131,31 @@ func CheckoutRepo(id string) (err error) {
return
}
syncLock.Lock()
defer syncLock.Unlock()
filesys.ReleaseAllFileLocks()
writingDataLock.Lock()
defer writingDataLock.Unlock()
CloseWatchAssets()
defer WatchAssets()
// 恢复快照时自动暂停同步,避免刚刚恢复后的数据又被同步覆盖
syncEnabled := Conf.Sync.Enabled
Conf.Sync.Enabled = false
Conf.Save()
err = repo.Checkout(id, util.PushEndlessProgress, checkoutCallbacks)
util.PushClearProgress()
if nil != err {
util.PushClearProgress()
return
}
RefreshFileTree()
if syncEnabled {
func() {
time.Sleep(5 * time.Second)
util.PushMsg(Conf.Language(134), 0)
}()
}
return
}
@ -151,7 +173,7 @@ var indexCallbacks = map[string]dejavu.Callback{
func IndexRepo(memo string) (err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New("repo key is nil")
err = errors.New(Conf.Language(26))
return
}
@ -168,9 +190,9 @@ func IndexRepo(memo string) (err error) {
}
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
filesys.ReleaseAllFileLocks()
writingDataLock.Lock()
defer writingDataLock.Unlock()
_, err = repo.Index(memo, util.PushEndlessProgress, indexCallbacks)
util.PushClearProgress()
return

View file

@ -578,7 +578,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
var src []byte
for _, attr := range nodes[0].Attr {
if "src" == attr.Key || "data-assets" == attr.Key {
if "src" == attr.Key || "data-assets" == attr.Key || "custom-data-assets" == attr.Key {
src = gulu.Str.ToBytes(attr.Val)
break
}