mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 不再自动从临时文件中恢复数据文件 Fix https://github.com/siyuan-note/siyuan/issues/7260
This commit is contained in:
parent
e7f2fb9c9c
commit
ae9ba8496f
3 changed files with 5 additions and 86 deletions
|
|
@ -22,7 +22,6 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
|
|
@ -79,44 +78,6 @@ func LastID(p string) (name, id string) {
|
|||
return
|
||||
}
|
||||
|
||||
func LatestTmpFile(p string) string {
|
||||
dir, base := filepath.Split(p)
|
||||
files, err := os.ReadDir(dir)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read dir [%s] failed: %s", dir, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
var tmps []os.DirEntry
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(f.Name(), ".tmp") && strings.HasPrefix(f.Name(), base) && len(base)+7+len(".tmp") == len(f.Name()) {
|
||||
tmps = append(tmps, f)
|
||||
}
|
||||
}
|
||||
|
||||
if 1 > len(tmps) {
|
||||
return ""
|
||||
}
|
||||
|
||||
sort.Slice(tmps, func(i, j int) bool {
|
||||
info1, err := tmps[i].Info()
|
||||
if nil != err {
|
||||
logging.LogErrorf("read file info [%s] failed: %s", tmps[i].Name(), err)
|
||||
return false
|
||||
}
|
||||
info2, err := tmps[j].Info()
|
||||
if nil != err {
|
||||
logging.LogErrorf("read file info [%s] failed: %s", tmps[j].Name(), err)
|
||||
return false
|
||||
}
|
||||
return info1.ModTime().After(info2.ModTime())
|
||||
})
|
||||
return filepath.Join(dir, tmps[0].Name())
|
||||
}
|
||||
|
||||
func IsCorruptedSYData(data []byte) bool {
|
||||
if 64 > len(data) || '{' != data[0] {
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue