mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
32e68973ca
@ -22,6 +22,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
@ -87,12 +88,26 @@ func importSyncProviderWebDAV(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpDir := filepath.Join(importDir, "webdav")
|
tmpDir := filepath.Join(importDir, "webdav")
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||||
logging.LogErrorf("import WebDAV provider failed: %s", err)
|
logging.LogErrorf("import WebDAV provider failed: %s", err)
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if strings.HasSuffix(strings.ToLower(tmp), ".json") {
|
||||||
|
if err = gulu.File.CopyFile(tmp, filepath.Join(tmpDir, f.Filename)); err != nil {
|
||||||
|
logging.LogErrorf("import WebDAV provider failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging.LogErrorf("invalid WebDAV provider package")
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "invalid WebDAV provider package"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
entries, err := os.ReadDir(tmpDir)
|
entries, err := os.ReadDir(tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -259,12 +274,26 @@ func importSyncProviderS3(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpDir := filepath.Join(importDir, "s3")
|
tmpDir := filepath.Join(importDir, "s3")
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||||
logging.LogErrorf("import S3 provider failed: %s", err)
|
logging.LogErrorf("import S3 provider failed: %s", err)
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if strings.HasSuffix(strings.ToLower(tmp), ".json") {
|
||||||
|
if err = gulu.File.CopyFile(tmp, filepath.Join(tmpDir, f.Filename)); err != nil {
|
||||||
|
logging.LogErrorf("import S3 provider failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging.LogErrorf("invalid S3 provider package")
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "invalid S3 provider package"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
entries, err := os.ReadDir(tmpDir)
|
entries, err := os.ReadDir(tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -408,12 +408,26 @@ func importConf(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpDir := filepath.Join(importDir, "conf")
|
tmpDir := filepath.Join(importDir, "conf")
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||||
logging.LogErrorf("import conf failed: %s", err)
|
logging.LogErrorf("import conf failed: %s", err)
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if strings.HasSuffix(strings.ToLower(tmp), ".json") {
|
||||||
|
if err = gulu.File.CopyFile(tmp, filepath.Join(tmpDir, f.Filename)); err != nil {
|
||||||
|
logging.LogErrorf("import conf failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging.LogErrorf("invalid conf package")
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "invalid conf package"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
entries, err := os.ReadDir(tmpDir)
|
entries, err := os.ReadDir(tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2120,6 +2120,37 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = av.SaveAttributeView(attrView)
|
err = av.SaveAttributeView(attrView)
|
||||||
|
|
||||||
|
historyDir, err := GetHistoryDir(HistoryOpUpdate)
|
||||||
|
if err != nil {
|
||||||
|
logging.LogErrorf("get history dir failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
|
||||||
|
for _, blockID := range blockIDs {
|
||||||
|
tree := trees[blockID]
|
||||||
|
if nil == tree {
|
||||||
|
tree, _ = LoadTreeByBlockID(blockID)
|
||||||
|
}
|
||||||
|
if nil == tree {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
historyPath := filepath.Join(historyDir, tree.Box, tree.Path)
|
||||||
|
absPath := filepath.Join(util.DataDir, tree.Box, tree.Path)
|
||||||
|
if err = filelock.Copy(absPath, historyPath); err != nil {
|
||||||
|
logging.LogErrorf("backup [path=%s] to history [%s] failed: %s", absPath, historyPath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
srcAvPath := filepath.Join(util.DataDir, "storage", "av", avID+".json")
|
||||||
|
destAvPath := filepath.Join(historyDir, "storage", "av", avID+".json")
|
||||||
|
if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr {
|
||||||
|
logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,10 @@ func DeleteOutdatedHistories(before int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IndexHistoriesQueue(histories []*History) {
|
func IndexHistoriesQueue(histories []*History) {
|
||||||
|
if 1 > len(histories) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
historyDBQueueLock.Lock()
|
historyDBQueueLock.Lock()
|
||||||
defer historyDBQueueLock.Unlock()
|
defer historyDBQueueLock.Unlock()
|
||||||
|
|
||||||
|
@ -125,20 +125,7 @@ func loadFonts() (ret []*Font) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if sfnt.PlatformLanguageID(1033) == e.LanguageID {
|
if sfnt.PlatformLanguageID(1033) == e.LanguageID || sfnt.PlatformLanguageID(2052) == e.LanguageID {
|
||||||
v, _, err := transform.Bytes(textUnicode.UTF16(textUnicode.BigEndian, textUnicode.IgnoreBOM).NewDecoder(), e.Value)
|
|
||||||
if err != nil {
|
|
||||||
//LogErrorf("decode font family [%s] failed: %s", fontPath, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
val := string(v)
|
|
||||||
if sfnt.NameFontFamily == e.NameID && "" != val {
|
|
||||||
family = val
|
|
||||||
}
|
|
||||||
if sfnt.NamePreferredFamily == e.NameID && "" != val {
|
|
||||||
family = val
|
|
||||||
}
|
|
||||||
} else if sfnt.PlatformLanguageID(2052) == e.LanguageID {
|
|
||||||
v, _, err := transform.Bytes(textUnicode.UTF16(textUnicode.BigEndian, textUnicode.IgnoreBOM).NewDecoder(), e.Value)
|
v, _, err := transform.Bytes(textUnicode.UTF16(textUnicode.BigEndian, textUnicode.IgnoreBOM).NewDecoder(), e.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//LogErrorf("decode font family [%s] failed: %s", fontPath, err)
|
//LogErrorf("decode font family [%s] failed: %s", fontPath, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user