Ver código fonte

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

Vanessa 8 meses atrás
pai
commit
1f050f4431
5 arquivos alterados com 21 adições e 17 exclusões
  1. 1 1
      kernel/go.mod
  2. 2 2
      kernel/go.sum
  3. 4 6
      kernel/model/box.go
  4. 3 3
      kernel/model/import.go
  5. 11 5
      kernel/model/repository.go

+ 1 - 1
kernel/go.mod

@@ -56,7 +56,7 @@ require (
 	github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
 	github.com/sashabaranov/go-openai v1.29.1
 	github.com/shirou/gopsutil/v3 v3.24.5
-	github.com/siyuan-note/dejavu v0.0.0-20241123152109-fc98d29be247
+	github.com/siyuan-note/dejavu v0.0.0-20241124021155-df73bbaf4338
 	github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4
 	github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97
 	github.com/siyuan-note/filelock v0.0.0-20241121021809-1cf0626a7d64

+ 2 - 2
kernel/go.sum

@@ -340,8 +340,8 @@ github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+D
 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/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8=
-github.com/siyuan-note/dejavu v0.0.0-20241123152109-fc98d29be247 h1:AS2ujNHMtejpoU/9W/k5U/iHW+qSgatPPXeiIQl/gPs=
-github.com/siyuan-note/dejavu v0.0.0-20241123152109-fc98d29be247/go.mod h1:KBNaIdV5TSJmWrdof7C7A46RhB0IVm8hofDox0zgMqA=
+github.com/siyuan-note/dejavu v0.0.0-20241124021155-df73bbaf4338 h1:rnuhUDyBLpKKIEuUhnUJXwE1SLemfNDzNKX/mWWkKl4=
+github.com/siyuan-note/dejavu v0.0.0-20241124021155-df73bbaf4338/go.mod h1:KBNaIdV5TSJmWrdof7C7A46RhB0IVm8hofDox0zgMqA=
 github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 h1:kJaw5L/evyW6LcB9IQT8PR4ppx8JVqOFP9Ix3rfwSrc=
 github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4/go.mod h1:UYcCCY+0wh+GmUoDOaO63j1sV5lgy7laLAk1XhEiUis=
 github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97 h1:lM5v8BfNtbOL5jYwhCdMYBcYtr06IYBKjjSLAPMKTM8=

+ 4 - 6
kernel/model/box.go

@@ -604,18 +604,16 @@ func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) {
 						continue
 					}
 
-					for i, tag := range attrV.([]any) {
-						tagStr := strings.TrimSpace(tag.(string))
+					for _, tag := range attrV.([]any) {
+						tagStr := fmt.Sprintf("%v", tag)
 						if "" == tag {
 							continue
 						}
 						tagStr = strings.TrimLeft(tagStr, "#,'\"")
 						tagStr = strings.TrimRight(tagStr, "#,'\"")
-						tags += tagStr
-						if i < len(attrV.([]any))-1 {
-							tags += ","
-						}
+						tags += tagStr + ","
 					}
+					tags = strings.TrimRight(tags, ",")
 					tree.Root.SetIALAttr("tags", tags)
 					continue
 				}

+ 3 - 3
kernel/model/import.go

@@ -740,7 +740,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
 
 			curRelPath := filepath.ToSlash(strings.TrimPrefix(currentPath, localPath))
 			targetPath := path.Join(baseTargetPath, id)
-			hPath := path.Join(baseHPath, filepath.ToSlash(strings.TrimPrefix(currentPath, localPath)))
+			hPath := path.Join(baseHPath, filepath.Base(localPath), filepath.ToSlash(strings.TrimPrefix(currentPath, localPath)))
 			hPath = strings.TrimSuffix(hPath, ext)
 			if "" == curRelPath {
 				curRelPath = "/"
@@ -798,7 +798,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
 			if "" != yfmTitle {
 				title = yfmTitle
 			}
-			unescapedTitle, unescapeErr := url.QueryUnescape(title)
+			unescapedTitle, unescapeErr := url.PathUnescape(title)
 			if nil == unescapeErr {
 				title = unescapedTitle
 			}
@@ -920,7 +920,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
 		if "" != yfmTitle {
 			title = yfmTitle
 		}
-		unescapedTitle, unescapeErr := url.QueryUnescape(title)
+		unescapedTitle, unescapeErr := url.PathUnescape(title)
 		if nil == unescapeErr {
 			title = unescapedTitle
 		}

+ 11 - 5
kernel/model/repository.go

@@ -752,7 +752,7 @@ func checkoutRepo(id string) {
 	// 回滚快照时默认为当前数据创建一个快照
 	// When rolling back a snapshot, a snapshot is created for the current data by default https://github.com/siyuan-note/siyuan/issues/12470
 	FlushTxQueue()
-	_, err = repo.Index("Backup before checkout", map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
+	_, err = repo.Index("Backup before checkout", false, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
 	if err != nil {
 		logging.LogErrorf("index repository failed: %s", err)
 		util.PushClearProgress()
@@ -1074,7 +1074,7 @@ func IndexRepo(memo string) (err error) {
 	start := time.Now()
 	latest, _ := repo.Latest()
 	FlushTxQueue()
-	index, err := repo.Index(memo, map[string]interface{}{
+	index, err := repo.Index(memo, true, map[string]interface{}{
 		eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress,
 	})
 	if err != nil {
@@ -1770,9 +1770,15 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (beforeIndex, afterIndex *entit
 
 	beforeIndex, _ = repo.Latest()
 	FlushTxQueue()
-	afterIndex, err = repo.Index("[Sync] Cloud sync", map[string]interface{}{
-		eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
-	})
+
+	checkChunks := true
+	if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container || util.ContainerHarmony == util.Container {
+		// 因为移动端私有数据空间不会存在外部操作导致分块损坏的情况,所以不需要检查分块以提升性能 https://github.com/siyuan-note/siyuan/issues/13216
+		checkChunks = false
+	}
+
+	afterIndex, err = repo.Index("[Sync] Cloud sync", checkChunks,
+		map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
 	if err != nil {
 		logging.LogErrorf("index data repo before cloud sync failed: %s", err)
 		return