🔥 移出遗留代码
This commit is contained in:
parent
d8b7b8aaac
commit
b3cf3745e5
3 changed files with 0 additions and 95 deletions
|
@ -191,72 +191,6 @@ func IndexRefs() {
|
|||
util.SetBootDetails("Resolving refs...")
|
||||
util.PushEndlessProgress(Conf.Language(54))
|
||||
|
||||
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress}
|
||||
// 解析并更新引用块
|
||||
util.SetBootDetails("Resolving ref block content...")
|
||||
refUnresolvedBlocks := sql.GetRefUnresolvedBlocks() // TODO: v2.2.0 以后移除
|
||||
if 0 < len(refUnresolvedBlocks) {
|
||||
dynamicRefTreeIDs := hashset.New()
|
||||
bootProgressPart := 10.0 / float64(len(refUnresolvedBlocks))
|
||||
anchors := map[string]string{}
|
||||
var refBlockIDs []string
|
||||
for i, refBlock := range refUnresolvedBlocks {
|
||||
util.IncBootProgress(bootProgressPart, "Resolving ref block content "+util.ShortPathForBootingDisplay(refBlock.ID))
|
||||
tx, err := sql.BeginTx()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
blockContent := sql.ResolveRefContent(refBlock, &anchors)
|
||||
refBlock.Content = blockContent
|
||||
refBlockIDs = append(refBlockIDs, refBlock.ID)
|
||||
dynamicRefTreeIDs.Add(refBlock.RootID)
|
||||
sql.CommitTx(tx)
|
||||
if 1 < i && 0 == i%64 {
|
||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(53), i, len(refUnresolvedBlocks)-i))
|
||||
}
|
||||
}
|
||||
|
||||
// 将需要更新动态引用文本内容的块先删除,后面会重新插入,这样比直接 update 快很多
|
||||
util.SetBootDetails("Deleting unresolved block content...")
|
||||
tx, err := sql.BeginTx()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
sql.DeleteBlockByIDs(tx, refBlockIDs)
|
||||
sql.CommitTx(tx)
|
||||
|
||||
bootProgressPart = 10.0 / float64(len(refUnresolvedBlocks))
|
||||
for i, refBlock := range refUnresolvedBlocks {
|
||||
util.IncBootProgress(bootProgressPart, "Updating block content "+util.ShortPathForBootingDisplay(refBlock.ID))
|
||||
tx, err = sql.BeginTx()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
sql.InsertBlock(tx, refBlock, context)
|
||||
sql.CommitTx(tx)
|
||||
if 1 < i && 0 == i%64 {
|
||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(53), i, len(refUnresolvedBlocks)-i))
|
||||
}
|
||||
}
|
||||
|
||||
if 0 < dynamicRefTreeIDs.Size() {
|
||||
// 块引锚文本静态化
|
||||
for _, dynamicRefTreeIDVal := range dynamicRefTreeIDs.Values() {
|
||||
dynamicRefTreeID := dynamicRefTreeIDVal.(string)
|
||||
util.IncBootProgress(bootProgressPart, "Persisting block ref text "+util.ShortPathForBootingDisplay(dynamicRefTreeID))
|
||||
tree, err := loadTreeByBlockID(dynamicRefTreeID)
|
||||
if nil != err {
|
||||
logging.LogErrorf("tree [%s] dynamic ref text to static failed: %s", dynamicRefTreeID, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := filesys.WriteTree(tree); nil == err {
|
||||
//logging.LogInfof("persisted tree [%s] dynamic ref text", tree.Box+tree.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 引用入库
|
||||
util.SetBootDetails("Indexing refs...")
|
||||
refBlocks := sql.GetRefExistedBlocks()
|
||||
|
|
|
@ -550,22 +550,6 @@ func GetAllChildBlocks(rootID, condition string) (ret []*Block) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetRefUnresolvedBlocks() (ret []*Block) {
|
||||
stmt := "SELECT * FROM blocks WHERE content LIKE ?"
|
||||
rows, err := query(stmt, "%ref resolve failed%")
|
||||
if nil != err {
|
||||
logging.LogErrorf("sql query [%s] failed: %s", stmt, err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
if block := scanBlockRows(rows); nil != block {
|
||||
ret = append(ret, block)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetRefExistedBlocks() (ret []*Block) {
|
||||
stmt := "SELECT * FROM blocks WHERE markdown LIKE ? OR markdown LIKE ?"
|
||||
rows, err := query(stmt, "%((20%", "%<<20%")
|
||||
|
|
|
@ -110,8 +110,6 @@ func Boot() {
|
|||
bootBanner := figure.NewColorFigure("SiYuan", "isometric3", "green", true)
|
||||
logging.LogInfof("\n" + bootBanner.String())
|
||||
logBootInfo()
|
||||
|
||||
go cleanOld()
|
||||
}
|
||||
|
||||
func setBootDetails(details string) {
|
||||
|
@ -322,17 +320,6 @@ func initPathDir() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: v2.2.0 移除
|
||||
func cleanOld() {
|
||||
dirs, _ := os.ReadDir(WorkingDir)
|
||||
for _, dir := range dirs {
|
||||
if strings.HasSuffix(dir.Name(), ".old") {
|
||||
old := filepath.Join(WorkingDir, dir.Name())
|
||||
os.RemoveAll(old)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkPort() {
|
||||
portOpened := isPortOpen(ServerPort)
|
||||
if !portOpened {
|
||||
|
|
Loading…
Add table
Reference in a new issue