mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-28 11:16:09 +01:00
🔥 移除旧版云端同步和备份功能入口 https://github.com/siyuan-note/siyuan/issues/5405
This commit is contained in:
parent
8e7fafbdfe
commit
51230a99c3
22 changed files with 63 additions and 177 deletions
|
|
@ -404,7 +404,7 @@ func RemoveUnusedAssets() (ret []string) {
|
|||
ret = append(ret, unusedAsset)
|
||||
}
|
||||
if 0 < len(ret) {
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -431,7 +431,7 @@ func RemoveUnusedAsset(p string) (ret string) {
|
|||
util.LogErrorf("remove unused asset [%s] failed: %s", p, err)
|
||||
}
|
||||
ret = p
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func watchAssets() {
|
|||
//util.LogInfof("assets changed: %s", lastEvent)
|
||||
if lastEvent.Op&fsnotify.Write == fsnotify.Write {
|
||||
// 外部修改已有资源文件后纳入云端同步 https://github.com/siyuan-note/siyuan/issues/4694
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func watchAssets() {
|
|||
|
||||
//util.LogInfof("assets changed: %s", event)
|
||||
if watcher.Write == event.Op {
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
}
|
||||
case err, ok := <-assetsWatcher.Error:
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ OK:
|
|||
if err = indexWriteJSONQueue(refTree); nil != err {
|
||||
return "", err
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
}
|
||||
sql.WaitForWritingDatabase()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func SetBlockReminder(id string, timed string) (err error) {
|
|||
if err = indexWriteJSONQueue(tree); nil != err {
|
||||
return
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
cache.PutBlockIAL(id, attrs)
|
||||
return
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|||
if err = indexWriteJSONQueue(tree); nil != err {
|
||||
return
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
cache.PutBlockIAL(id, parse.IAL2Map(node.KramdownIAL))
|
||||
return
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ func ResetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|||
if err = indexWriteJSONQueue(tree); nil != err {
|
||||
return
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
cache.RemoveBlockIAL(id)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ func (box *Box) Mkdir(path string) error {
|
|||
util.LogErrorf("mkdir [path=%s] in box [%s] failed: %s", path, box.ID, err)
|
||||
return errors.New(msg)
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ func (box *Box) MkdirAll(path string) error {
|
|||
util.LogErrorf("mkdir all [path=%s] in box [%s] failed: %s", path, box.ID, err)
|
||||
return errors.New(msg)
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ func (box *Box) Move(oldPath, newPath string) error {
|
|||
os.Remove(fromDir)
|
||||
}
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ func (box *Box) Remove(path string) error {
|
|||
util.LogErrorf("remove [path=%s] in box [%s] failed: %s", path, box.ID, err)
|
||||
return errors.New(msg)
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1130,7 +1130,7 @@ func MoveDoc(fromBoxID, fromPath, toBoxID, toPath string) (newPath string, err e
|
|||
moveSorts(tree.ID, fromBoxID, toBoxID)
|
||||
}
|
||||
cache.ClearDocsIAL()
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1251,7 +1251,7 @@ func RenameDoc(boxID, p, title string) (err error) {
|
|||
refreshDynamicRefText(changedDefs, changedTrees)
|
||||
}()
|
||||
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1319,7 +1319,7 @@ func CreateDailyNote(boxID string) (p string, err error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
|
||||
b := treenode.GetBlockTree(id)
|
||||
p = b.Path
|
||||
|
|
@ -1559,7 +1559,7 @@ func ChangeFileTreeSort(boxID string, paths []string) {
|
|||
return
|
||||
}
|
||||
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
}
|
||||
|
||||
func (box *Box) fillSort(files *[]*File) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func (tx *Transaction) doFoldHeading(operation *Operation) (ret *TxErr) {
|
|||
if err = tx.writeTree(tree); nil != err {
|
||||
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: headingID}
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
|
||||
cache.PutBlockIAL(headingID, parse.IAL2Map(heading.KramdownIAL))
|
||||
for _, child := range children {
|
||||
|
|
@ -89,7 +89,7 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
|
|||
if err = tx.writeTree(tree); nil != err {
|
||||
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: headingID}
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
|
||||
cache.PutBlockIAL(headingID, parse.IAL2Map(heading.KramdownIAL))
|
||||
for _, child := range children {
|
||||
|
|
@ -208,7 +208,7 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
|||
|
||||
targetTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
|
||||
err = indexWriteJSONQueue(targetTree)
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
RefreshBacklink(srcTree.ID)
|
||||
RefreshBacklink(targetTree.ID)
|
||||
return
|
||||
|
|
@ -306,7 +306,7 @@ func Heading2Doc(srcHeadingID, targetBoxID, targetPath string) (srcRootBlockID,
|
|||
if err = indexWriteJSONQueue(newTree); nil != err {
|
||||
return "", "", err
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
RefreshBacklink(srcTree.ID)
|
||||
RefreshBacklink(newTree.ID)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
|||
writingDataLock.Unlock()
|
||||
|
||||
RefreshFileTree()
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ func RollbackAssetsHistory(historyPath string) (err error) {
|
|||
util.LogErrorf("copy file [%s] to [%s] failed: %s", from, to, err)
|
||||
return
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ func RollbackNotebookHistory(historyPath string) (err error) {
|
|||
}
|
||||
|
||||
RefreshFileTree()
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
RefreshFileTree()
|
||||
return
|
||||
}
|
||||
|
|
@ -303,48 +303,27 @@ func ImportData(zipPath string) (err error) {
|
|||
}
|
||||
defer os.RemoveAll(unzipPath)
|
||||
|
||||
files, err := filepath.Glob(filepath.Join(unzipPath, "*/.siyuan/conf.json"))
|
||||
files, err := filepath.Glob(filepath.Join(unzipPath, "*/*.sy"))
|
||||
if nil != err {
|
||||
util.LogErrorf("glob conf.json failed: %s", err)
|
||||
return errors.New("not found conf.json")
|
||||
util.LogErrorf("check data.zip failed: %s", err)
|
||||
return errors.New("check data.zip failed")
|
||||
}
|
||||
if 1 > len(files) {
|
||||
return errors.New("not found conf.json")
|
||||
}
|
||||
|
||||
confPath := files[0]
|
||||
confData, err := os.ReadFile(confPath)
|
||||
if nil != err {
|
||||
return errors.New("read conf.json failed")
|
||||
}
|
||||
dataConf := &filesys.DataConf{}
|
||||
if err = gulu.JSON.UnmarshalJSON(confData, dataConf); nil != err {
|
||||
util.LogErrorf("unmarshal conf.json failed: %s", err)
|
||||
return errors.New("unmarshal conf.json failed")
|
||||
}
|
||||
dataConf.Device = util.GetDeviceID()
|
||||
confData, err = gulu.JSON.MarshalJSON(dataConf)
|
||||
if nil != err {
|
||||
util.LogErrorf("marshal conf.json failed: %s", err)
|
||||
return errors.New("marshal conf.json failed")
|
||||
}
|
||||
if err = os.WriteFile(confPath, confData, 0644); nil != err {
|
||||
util.LogErrorf("write conf.json failed: %s", err)
|
||||
return errors.New("write conf.json failed")
|
||||
if 0 < len(files) {
|
||||
return errors.New("invalid data.zip")
|
||||
}
|
||||
|
||||
writingDataLock.Lock()
|
||||
defer writingDataLock.Unlock()
|
||||
|
||||
filelock.ReleaseAllFileLocks()
|
||||
tmpDataPath := filepath.Dir(filepath.Dir(confPath))
|
||||
tmpDataPath := unzipPath
|
||||
if err = stableCopy(tmpDataPath, util.DataDir); nil != err {
|
||||
util.LogErrorf("copy data dir from [%s] to [%s] failed: %s", tmpDataPath, util.DataDir, err)
|
||||
err = errors.New("copy data failed")
|
||||
return
|
||||
}
|
||||
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
RefreshFileTree()
|
||||
return
|
||||
}
|
||||
|
|
@ -516,7 +495,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
RefreshFileTree()
|
||||
} else { // 导入单个文件
|
||||
fileName := filepath.Base(localPath)
|
||||
|
|
@ -588,7 +567,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
if err = indexWriteJSONQueue(tree); nil != err {
|
||||
return
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
sql.WaitForWritingDatabase()
|
||||
|
||||
util.PushEndlessProgress(Conf.Language(58))
|
||||
|
|
@ -598,7 +577,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
}()
|
||||
}
|
||||
debug.FreeOSMemory()
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
|
|||
if err = indexWriteJSONQueue(newTree); nil != err {
|
||||
return "", "", err
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
RefreshBacklink(srcTree.ID)
|
||||
RefreshBacklink(newTree.ID)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func CreateBox(name string) (id string, err error) {
|
|||
boxConf := box.GetConf()
|
||||
boxConf.Name = name
|
||||
box.SaveConf(boxConf)
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ func RenameBox(boxID, name string) (err error) {
|
|||
boxConf.Name = name
|
||||
box.Name = name
|
||||
box.SaveConf(boxConf)
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ func RemoveBox(boxID string) (err error) {
|
|||
if err = os.RemoveAll(localPath); nil != err {
|
||||
return
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/siyuan-note/dejavu"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -347,8 +346,7 @@ func getIgnoreLines() (ret []string) {
|
|||
return
|
||||
}
|
||||
|
||||
func IncWorkspaceDataVer() {
|
||||
filesys.IncWorkspaceDataVer(true, Conf.System.ID)
|
||||
func IncSync() {
|
||||
syncSameCount = 0
|
||||
planSyncAfter(30 * time.Second)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1107,7 +1107,7 @@ func (tx *Transaction) commit() (err error) {
|
|||
}
|
||||
}
|
||||
refreshDynamicRefText(tx.nodes, tx.trees)
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
tx.trees = nil
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func InsertLocalAssets(id string, assetPaths []string) (succMap map[string]inter
|
|||
succMap[baseName] = "assets/" + fName
|
||||
}
|
||||
}
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ func Upload(c *gin.Context) {
|
|||
"succMap": succMap,
|
||||
}
|
||||
|
||||
IncWorkspaceDataVer()
|
||||
IncSync()
|
||||
}
|
||||
|
||||
func getAssetsDir(boxLocalPath, docDirLocalPath string) (assets string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue