mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 16:26:09 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
d7f6456424
5 changed files with 30 additions and 41 deletions
|
|
@ -36,7 +36,7 @@ require (
|
|||
github.com/panjf2000/ants/v2 v2.6.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102102630-25556844ddab
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102120909-ed9ad2509c64
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
||||
github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef
|
||||
|
|
|
|||
|
|
@ -353,10 +353,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
|
|||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102101918-9258bfd2c7ca h1:yxlwyy/GxuzIBhTadAxjXNGAJYc3yrTjX8Yqq1SlVg4=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102101918-9258bfd2c7ca/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102102630-25556844ddab h1:pQJRm7GFp7DS3kCqlGVLq5T1jnIVNwOytbkr1BjByvY=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102102630-25556844ddab/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102120909-ed9ad2509c64 h1:psY8hXz/t7cwqJFR+6+vebb5s3P1AzqfkaJ+gIQGLjw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102120909-ed9ad2509c64/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||
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-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
||||
|
|
|
|||
|
|
@ -317,8 +317,7 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []*History
|
|||
}
|
||||
|
||||
pageSize := 32
|
||||
from := (page - 1) * pageSize
|
||||
to := page * pageSize
|
||||
offset := (page - 1) * pageSize
|
||||
|
||||
table := "histories_fts_case_insensitive"
|
||||
stmt := "SELECT * FROM " + table + " WHERE "
|
||||
|
|
@ -341,7 +340,7 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []*History
|
|||
stmt += " AND path LIKE '%/assets/%'"
|
||||
}
|
||||
countStmt := strings.ReplaceAll(stmt, "SELECT *", "SELECT COUNT(*) AS total")
|
||||
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(from) + ", " + strconv.Itoa(to)
|
||||
stmt += " ORDER BY created DESC LIMIT " + strconv.Itoa(pageSize) + " OFFSET " + strconv.Itoa(offset)
|
||||
sqlHistories := sql.SelectHistoriesRawStmt(stmt)
|
||||
ret = fromSQLHistories(sqlHistories)
|
||||
result, err := sql.QueryHistory(countStmt)
|
||||
|
|
@ -660,12 +659,9 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*History) {
|
|||
}
|
||||
|
||||
var items []*HistoryItem
|
||||
var tmpTime int64
|
||||
tmpTime, _ := strconv.ParseInt(sqlHistories[0].Created, 10, 64)
|
||||
for _, sqlHistory := range sqlHistories {
|
||||
unixSec, _ := strconv.ParseInt(sqlHistory.Created, 10, 64)
|
||||
if 0 == tmpTime {
|
||||
tmpTime = unixSec
|
||||
}
|
||||
if tmpTime == unixSec {
|
||||
item := &HistoryItem{
|
||||
Title: sqlHistory.Title,
|
||||
|
|
@ -691,6 +687,7 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*History) {
|
|||
items = []*HistoryItem{}
|
||||
items = append(items, item)
|
||||
}
|
||||
tmpTime = unixSec
|
||||
}
|
||||
if 0 < len(items) {
|
||||
ret = append(ret, &History{
|
||||
|
|
|
|||
|
|
@ -1009,7 +1009,7 @@ func subscribeEvents() {
|
|||
}
|
||||
|
||||
func buildCloudConf() (ret *cloud.Conf, err error) {
|
||||
if !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
logging.LogWarnf("invalid cloud repo name, rename it to [main]")
|
||||
Conf.Sync.CloudName = "main"
|
||||
Conf.Save()
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/siyuan-note/dejavu/cloud"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -70,7 +70,11 @@ func BootSyncData() {
|
|||
util.IncBootProgress(3, "Syncing data from the cloud...")
|
||||
BootSyncSucc = 0
|
||||
|
||||
if !IsSubscriber() || !Conf.Sync.Enabled || "" == Conf.Sync.CloudName || !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if !Conf.Sync.Enabled || !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
return
|
||||
}
|
||||
|
||||
if !IsSubscriber() && conf.ProviderSiYuan == Conf.Sync.Provider {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -124,18 +128,26 @@ func SyncData(boot, exit, byHand bool) {
|
|||
if exit {
|
||||
ExitSyncSucc = 0
|
||||
}
|
||||
if !IsSubscriber() || !Conf.Sync.Enabled || "" == Conf.Sync.CloudName {
|
||||
|
||||
if !Conf.Sync.Enabled {
|
||||
if byHand {
|
||||
if "" == Conf.Sync.CloudName {
|
||||
util.PushMsg(Conf.Language(123), 5000)
|
||||
} else if !Conf.Sync.Enabled {
|
||||
util.PushMsg(Conf.Language(124), 5000)
|
||||
}
|
||||
util.PushMsg(Conf.Language(124), 5000)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if byHand {
|
||||
util.PushMsg(Conf.Language(123), 5000)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if !IsSubscriber() && conf.ProviderSiYuan == Conf.Sync.Provider {
|
||||
return
|
||||
}
|
||||
|
||||
if !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +309,7 @@ func CreateCloudSyncDir(name string) (err error) {
|
|||
|
||||
name = strings.TrimSpace(name)
|
||||
name = gulu.Str.RemoveInvisible(name)
|
||||
if !IsValidCloudDirName(name) {
|
||||
if !cloud.IsValidCloudDirName(name) {
|
||||
return errors.New(Conf.Language(37))
|
||||
}
|
||||
|
||||
|
|
@ -405,24 +417,6 @@ func formatErrorMsg(err error) string {
|
|||
return msg
|
||||
}
|
||||
|
||||
func IsValidCloudDirName(cloudDirName string) bool {
|
||||
if 16 < utf8.RuneCountInString(cloudDirName) || 1 > utf8.RuneCountInString(cloudDirName) {
|
||||
return false
|
||||
}
|
||||
|
||||
chars := []byte{'~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=',
|
||||
'[', ']', '{', '}', '\\', '|', ';', ':', '\'', '"', '<', ',', '>', '.', '?', '/', ' '}
|
||||
var charsStr string
|
||||
for _, char := range chars {
|
||||
charsStr += string(char)
|
||||
}
|
||||
|
||||
if strings.ContainsAny(cloudDirName, charsStr) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func getIgnoreLines() (ret []string) {
|
||||
ignore := filepath.Join(util.DataDir, ".siyuan", "syncignore")
|
||||
err := os.MkdirAll(filepath.Dir(ignore), 0755)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue