Browse Source

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 3 years ago
parent
commit
2b61616d06

+ 1 - 1
app/appearance/langs/en_US.json

@@ -466,7 +466,7 @@
   "account10": "Annual subscription",
   "account10": "Annual subscription",
   "account11": "Until the end of the early bird discount",
   "account11": "Until the end of the early bird discount",
   "account12": "Life companion",
   "account12": "Life companion",
-  "account13": "Après avoir utilisé le code de parrainage, les remboursements ne seront plus pris en charge. Faut-il utiliser le code d'abonnement ?",
+  "clickMeToRenew": "<a href=\"https://ld246.com/subscribe/siyuan\" target=\"_blank\">Go to Renew</a>",
   "priceAnnual": "$72",
   "priceAnnual": "$72",
   "year": "year",
   "year": "year",
   "dataHistory": "Data History",
   "dataHistory": "Data History",

+ 1 - 1
app/appearance/langs/fr_FR.json

@@ -466,7 +466,7 @@
   "account10": "Abonnement annuel",
   "account10": "Abonnement annuel",
   "account11": "Jusqu'à la fin de la réduction pour les early bird",
   "account11": "Jusqu'à la fin de la réduction pour les early bird",
   "account12": "Compagnon de vie",
   "account12": "Compagnon de vie",
-  "account13": "Les remboursements ne seront plus pris en charge après l'utilisation du code d'abonnement. Devriez-vous utiliser le code d'abonnement ?",
+  "clickMeToRenew": "<a href=\"https://ld246.com/subscribe/siyuan\" target=\"_blank\">Aller à renouveler</a>",
   "priceAnnual": "$72",
   "priceAnnual": "$72",
   "year": "année",
   "year": "année",
   "dataHistory": "Historique des données",
   "dataHistory": "Historique des données",

+ 1 - 1
app/appearance/langs/zh_CHT.json

@@ -466,7 +466,7 @@
   "account10": "年付訂閱",
   "account10": "年付訂閱",
   "account11": "早鳥優惠活動結束還剩",
   "account11": "早鳥優惠活動結束還剩",
   "account12": "相伴一生",
   "account12": "相伴一生",
-  "account13": "使用推薦碼後將不再支援退款,是否使用推薦碼?",
+  "clickMeToRenew": "<a href=\"https://ld246.com/subscribe/siyuan\" target=\"_blank\">前往續訂</a>",
   "priceAnnual": "¥148",
   "priceAnnual": "¥148",
   "year": "年",
   "year": "年",
   "dataHistory": "數據歷史",
   "dataHistory": "數據歷史",

+ 1 - 1
app/appearance/langs/zh_CN.json

@@ -466,7 +466,7 @@
   "account10": "年付订阅",
   "account10": "年付订阅",
   "account11": "早鸟优惠活动结束还剩",
   "account11": "早鸟优惠活动结束还剩",
   "account12": "相伴一生",
   "account12": "相伴一生",
-  "account13": "使用推荐码后将不再支持退款,是否使用推荐码?",
+  "clickMeToRenew": "<a href=\"https://ld246.com/subscribe/siyuan\" target=\"_blank\">前往续订</a>",
   "priceAnnual": "¥148",
   "priceAnnual": "¥148",
   "year": "年",
   "year": "年",
   "dataHistory": "数据历史",
   "dataHistory": "数据历史",

+ 1 - 1
app/src/config/account.ts

@@ -52,7 +52,7 @@ export const account = {
                 subscriptionHTML = `<div class="b3-chip b3-chip--secondary">${Constants.SIYUAN_IMAGE_VIP}${window.siyuan.languages.account12}</div>`;
                 subscriptionHTML = `<div class="b3-chip b3-chip--secondary">${Constants.SIYUAN_IMAGE_VIP}${window.siyuan.languages.account12}</div>`;
             } else if (window.siyuan.user.userSiYuanProExpireTime > 0) {
             } else if (window.siyuan.user.userSiYuanProExpireTime > 0) {
                 subscriptionHTML = `<div class="b3-chip b3-chip--primary"><svg class="ft__secondary"><use xlink:href="#iconVIP"></use></svg>${window.siyuan.languages.account10}</div><div class="fn__hr"></div>
                 subscriptionHTML = `<div class="b3-chip b3-chip--primary"><svg class="ft__secondary"><use xlink:href="#iconVIP"></use></svg>${window.siyuan.languages.account10}</div><div class="fn__hr"></div>
-<div class="ft__on-surface ft__smaller">${window.siyuan.languages.account6} ${Math.floor((window.siyuan.user.userSiYuanProExpireTime - new Date().getTime()) / 1000 / 60 / 60 / 24)} ${window.siyuan.languages.day}</div>`;
+<div class="ft__on-surface ft__smaller">${window.siyuan.languages.account6} ${Math.floor((window.siyuan.user.userSiYuanProExpireTime - new Date().getTime()) / 1000 / 60 / 60 / 24)} ${window.siyuan.languages.day} ${window.siyuan.languages.clickMeToRenew}</div>`;
             }
             }
             return `<div class="fn__flex config-account">
             return `<div class="fn__flex config-account">
 <div class="config-account__center">
 <div class="config-account__center">

+ 1 - 11
kernel/model/backup.go

@@ -145,8 +145,6 @@ func RecoverLocalBackup() (err error) {
 	data, _ = hex.DecodeString(string(data))
 	data, _ = hex.DecodeString(string(data))
 	passwd := string(data)
 	passwd := string(data)
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
 	CloseWatchAssets()
 	CloseWatchAssets()
 	defer WatchAssets()
 	defer WatchAssets()
 
 
@@ -233,7 +231,7 @@ func RecoverLocalBackup() (err error) {
 
 
 	util.PushEndlessProgress(Conf.Language(62))
 	util.PushEndlessProgress(Conf.Language(62))
 	time.Sleep(2 * time.Second)
 	time.Sleep(2 * time.Second)
-	refreshFileTree()
+	RefreshFileTree()
 	if syncEnabled {
 	if syncEnabled {
 		func() {
 		func() {
 			time.Sleep(5 * time.Second)
 			time.Sleep(5 * time.Second)
@@ -252,8 +250,6 @@ func CreateLocalBackup() (err error) {
 	util.PushEndlessProgress(Conf.Language(22))
 	util.PushEndlessProgress(Conf.Language(22))
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
 
 
 	filesys.ReleaseAllFileLocks()
 	filesys.ReleaseAllFileLocks()
 
 
@@ -326,9 +322,6 @@ func CreateLocalBackup() (err error) {
 }
 }
 
 
 func DownloadBackup() (err error) {
 func DownloadBackup() (err error) {
-	syncLock.Lock()
-	defer syncLock.Unlock()
-
 	// 使用索引文件进行解密验证 https://github.com/siyuan-note/siyuan/issues/3789
 	// 使用索引文件进行解密验证 https://github.com/siyuan-note/siyuan/issues/3789
 	var tmpFetchedFiles int
 	var tmpFetchedFiles int
 	var tmpTransferSize uint64
 	var tmpTransferSize uint64
@@ -367,9 +360,6 @@ func UploadBackup() (err error) {
 		return
 		return
 	}
 	}
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
-
 	localDirPath := Conf.Backup.GetSaveDir()
 	localDirPath := Conf.Backup.GetSaveDir()
 	util.PushEndlessProgress(Conf.Language(61))
 	util.PushEndlessProgress(Conf.Language(61))
 	util.LogInfof("uploading backup...")
 	util.LogInfof("uploading backup...")

+ 16 - 16
kernel/model/bazzar.go

@@ -50,8 +50,8 @@ func BazaarWidgets() (widgets []*bazaar.Widget) {
 }
 }
 
 
 func InstallBazaarWidget(repoURL, repoHash, widgetName string) error {
 func InstallBazaarWidget(repoURL, repoHash, widgetName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	installPath := filepath.Join(util.DataDir, "widgets", widgetName)
 	installPath := filepath.Join(util.DataDir, "widgets", widgetName)
 	err := bazaar.InstallWidget(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
 	err := bazaar.InstallWidget(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
@@ -62,8 +62,8 @@ func InstallBazaarWidget(repoURL, repoHash, widgetName string) error {
 }
 }
 
 
 func UninstallBazaarWidget(widgetName string) error {
 func UninstallBazaarWidget(widgetName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	installPath := filepath.Join(util.DataDir, "widgets", widgetName)
 	installPath := filepath.Join(util.DataDir, "widgets", widgetName)
 	err := bazaar.UninstallWidget(installPath)
 	err := bazaar.UninstallWidget(installPath)
@@ -92,8 +92,8 @@ func BazaarIcons() (icons []*bazaar.Icon) {
 }
 }
 
 
 func InstallBazaarIcon(repoURL, repoHash, iconName string) error {
 func InstallBazaarIcon(repoURL, repoHash, iconName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	installPath := filepath.Join(util.IconsPath, iconName)
 	installPath := filepath.Join(util.IconsPath, iconName)
 	err := bazaar.InstallIcon(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
 	err := bazaar.InstallIcon(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
@@ -107,8 +107,8 @@ func InstallBazaarIcon(repoURL, repoHash, iconName string) error {
 }
 }
 
 
 func UninstallBazaarIcon(iconName string) error {
 func UninstallBazaarIcon(iconName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	installPath := filepath.Join(util.IconsPath, iconName)
 	installPath := filepath.Join(util.IconsPath, iconName)
 	err := bazaar.UninstallIcon(installPath)
 	err := bazaar.UninstallIcon(installPath)
@@ -139,8 +139,8 @@ func BazaarThemes() (ret []*bazaar.Theme) {
 }
 }
 
 
 func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bool) error {
 func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bool) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	closeThemeWatchers()
 	closeThemeWatchers()
 
 
@@ -167,8 +167,8 @@ func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bo
 }
 }
 
 
 func UninstallBazaarTheme(themeName string) error {
 func UninstallBazaarTheme(themeName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	closeThemeWatchers()
 	closeThemeWatchers()
 
 
@@ -198,8 +198,8 @@ func BazaarTemplates() (templates []*bazaar.Template) {
 }
 }
 
 
 func InstallBazaarTemplate(repoURL, repoHash, templateName string) error {
 func InstallBazaarTemplate(repoURL, repoHash, templateName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	installPath := filepath.Join(util.DataDir, "templates", templateName)
 	installPath := filepath.Join(util.DataDir, "templates", templateName)
 	err := bazaar.InstallTemplate(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
 	err := bazaar.InstallTemplate(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
@@ -210,8 +210,8 @@ func InstallBazaarTemplate(repoURL, repoHash, templateName string) error {
 }
 }
 
 
 func UninstallBazaarTemplate(templateName string) error {
 func UninstallBazaarTemplate(templateName string) error {
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	installPath := filepath.Join(util.DataDir, "templates", templateName)
 	installPath := filepath.Join(util.DataDir, "templates", templateName)
 	err := bazaar.UninstallTemplate(installPath)
 	err := bazaar.UninstallTemplate(installPath)

+ 0 - 5
kernel/model/box.go

@@ -474,12 +474,7 @@ func parseKTree(kramdown []byte) (ret *parse.Tree) {
 
 
 func RefreshFileTree() {
 func RefreshFileTree() {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
-	refreshFileTree()
-}
 
 
-func refreshFileTree() {
 	if err := sql.InitDatabase(true); nil != err {
 	if err := sql.InitDatabase(true); nil != err {
 		util.PushErrMsg(Conf.Language(85), 5000)
 		util.PushErrMsg(Conf.Language(85), 5000)
 		return
 		return

+ 6 - 4
kernel/model/export.go

@@ -74,8 +74,9 @@ func ExportDataInFolder(exportFolder string) (err error) {
 	util.PushEndlessProgress(Conf.Language(65))
 	util.PushEndlessProgress(Conf.Language(65))
 	defer util.ClearPushProgress(100)
 	defer util.ClearPushProgress(100)
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	WaitForWritingFiles()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	exportFolder = filepath.Join(exportFolder, util.CurrentTimeSecondsStr())
 	exportFolder = filepath.Join(exportFolder, util.CurrentTimeSecondsStr())
 	err = exportData(exportFolder)
 	err = exportData(exportFolder)
@@ -89,8 +90,9 @@ func ExportData() (zipPath string) {
 	util.PushEndlessProgress(Conf.Language(65))
 	util.PushEndlessProgress(Conf.Language(65))
 	defer util.ClearPushProgress(100)
 	defer util.ClearPushProgress(100)
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	WaitForWritingFiles()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	baseFolderName := "data-" + util.CurrentTimeSecondsStr()
 	baseFolderName := "data-" + util.CurrentTimeSecondsStr()
 	exportFolder := filepath.Join(util.TempDir, "export", baseFolderName)
 	exportFolder := filepath.Join(util.TempDir, "export", baseFolderName)

+ 6 - 18
kernel/model/file.go

@@ -841,9 +841,6 @@ func DuplicateDoc(rootID string) (err error) {
 	defer util.PushClearMsg()
 	defer util.PushClearMsg()
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
-
 	tree, err := loadTreeByBlockID(rootID)
 	tree, err := loadTreeByBlockID(rootID)
 	if nil != err {
 	if nil != err {
 		return
 		return
@@ -890,8 +887,6 @@ func DuplicateDoc(rootID string) (err error) {
 
 
 func CreateDocByMd(boxID, p, title, md string) (err error) {
 func CreateDocByMd(boxID, p, title, md string) (err error) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
 
 
 	box := Conf.Box(boxID)
 	box := Conf.Box(boxID)
 	if nil == box {
 	if nil == box {
@@ -911,9 +906,6 @@ func CreateWithMarkdown(boxID, hPath, md string) (id string, err error) {
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
-
 	luteEngine := NewLute()
 	luteEngine := NewLute()
 	dom := luteEngine.Md2BlockDOM(md)
 	dom := luteEngine.Md2BlockDOM(md)
 	id, err = createDocsByHPath(box.ID, hPath, dom)
 	id, err = createDocsByHPath(box.ID, hPath, dom)
@@ -981,8 +973,8 @@ func MoveDoc(fromBoxID, fromPath, toBoxID, toPath string) (newPath string, err e
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	tree, err := LoadTree(fromBoxID, fromPath)
 	tree, err := LoadTree(fromBoxID, fromPath)
 	if nil != err {
 	if nil != err {
@@ -1109,8 +1101,8 @@ func RemoveDoc(boxID, p string) (err error) {
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	tree, err := LoadTree(boxID, p)
 	tree, err := LoadTree(boxID, p)
 	if nil != err {
 	if nil != err {
@@ -1241,8 +1233,6 @@ func CreateDailyNote(boxID string) (p string, err error) {
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
 
 
 	existRoot := treenode.GetBlockTreeRootByHPath(box.ID, hPath)
 	existRoot := treenode.GetBlockTreeRootByHPath(box.ID, hPath)
 	if nil != existRoot {
 	if nil != existRoot {
@@ -1453,8 +1443,8 @@ func rootChildIDs(rootID string) (ret []string) {
 
 
 func ChangeFileTreeSort(boxID string, paths []string) {
 func ChangeFileTreeSort(boxID string, paths []string) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	box := Conf.Box(boxID)
 	box := Conf.Box(boxID)
 	sortIDs := map[string]int{}
 	sortIDs := map[string]int{}
@@ -1609,8 +1599,6 @@ func (box *Box) removeSort(rootID, path string) {
 
 
 func ServeFile(c *gin.Context, filePath string) (err error) {
 func ServeFile(c *gin.Context, filePath string) (err error) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
 
 
 	if filesys.IsLocked(filePath) {
 	if filesys.IsLocked(filePath) {
 		if err = filesys.UnlockFile(filePath); nil == err {
 		if err = filesys.UnlockFile(filePath); nil == err {

+ 5 - 8
kernel/model/history.go

@@ -50,9 +50,6 @@ func generateDocHistory() {
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
-
 	for _, box := range Conf.GetOpenedBoxes() {
 	for _, box := range Conf.GetOpenedBoxes() {
 		box.generateDocHistory0()
 		box.generateDocHistory0()
 	}
 	}
@@ -158,7 +155,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
+	writingDataLock.Lock()
 
 
 	srcPath := historyPath
 	srcPath := historyPath
 	var destPath string
 	var destPath string
@@ -169,22 +166,22 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
 	workingDoc := treenode.GetBlockTree(id)
 	workingDoc := treenode.GetBlockTree(id)
 	if nil != workingDoc {
 	if nil != workingDoc {
 		if err = os.RemoveAll(filepath.Join(util.DataDir, boxID, workingDoc.Path)); nil != err {
 		if err = os.RemoveAll(filepath.Join(util.DataDir, boxID, workingDoc.Path)); nil != err {
-			syncLock.Unlock()
+			writingDataLock.Unlock()
 			return
 			return
 		}
 		}
 	}
 	}
 
 
 	destPath, err = getRollbackDockPath(boxID, historyPath)
 	destPath, err = getRollbackDockPath(boxID, historyPath)
 	if nil != err {
 	if nil != err {
-		syncLock.Unlock()
+		writingDataLock.Unlock()
 		return
 		return
 	}
 	}
 
 
 	if err = gulu.File.Copy(srcPath, destPath); nil != err {
 	if err = gulu.File.Copy(srcPath, destPath); nil != err {
-		syncLock.Unlock()
+		writingDataLock.Unlock()
 		return
 		return
 	}
 	}
-	syncLock.Unlock()
+	writingDataLock.Unlock()
 
 
 	RefreshFileTree()
 	RefreshFileTree()
 	IncWorkspaceDataVer()
 	IncWorkspaceDataVer()

+ 9 - 9
kernel/model/import.go

@@ -250,8 +250,8 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
 		}
 		}
 	}
 	}
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	filesys.ReleaseAllFileLocks()
 	filesys.ReleaseAllFileLocks()
 
 
@@ -279,7 +279,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
 	}
 	}
 
 
 	IncWorkspaceDataVer()
 	IncWorkspaceDataVer()
-	refreshFileTree()
+	RefreshFileTree()
 	return
 	return
 }
 }
 
 
@@ -327,8 +327,8 @@ func ImportData(zipPath string) (err error) {
 		return errors.New("write conf.json failed")
 		return errors.New("write conf.json failed")
 	}
 	}
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	filesys.ReleaseAllFileLocks()
 	filesys.ReleaseAllFileLocks()
 	tmpDataPath := filepath.Dir(filepath.Dir(confPath))
 	tmpDataPath := filepath.Dir(filepath.Dir(confPath))
@@ -339,7 +339,7 @@ func ImportData(zipPath string) (err error) {
 	}
 	}
 
 
 	IncWorkspaceDataVer()
 	IncWorkspaceDataVer()
-	refreshFileTree()
+	RefreshFileTree()
 	return
 	return
 }
 }
 
 
@@ -347,8 +347,8 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
 	util.PushEndlessProgress(Conf.Language(73))
 	util.PushEndlessProgress(Conf.Language(73))
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	box := Conf.Box(boxID)
 	box := Conf.Box(boxID)
 	var baseHPath, baseTargetPath, boxLocalPath string
 	var baseHPath, baseTargetPath, boxLocalPath string
@@ -510,7 +510,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
 		}
 		}
 
 
 		IncWorkspaceDataVer()
 		IncWorkspaceDataVer()
-		refreshFileTree()
+		RefreshFileTree()
 	} else { // 导入单个文件
 	} else { // 导入单个文件
 		fileName := filepath.Base(localPath)
 		fileName := filepath.Base(localPath)
 		if !strings.HasSuffix(fileName, ".md") && !strings.HasSuffix(fileName, ".markdown") {
 		if !strings.HasSuffix(fileName, ".md") && !strings.HasSuffix(fileName, ".markdown") {

+ 10 - 10
kernel/model/mount.go

@@ -34,8 +34,8 @@ import (
 
 
 func CreateBox(name string) (id string, err error) {
 func CreateBox(name string) (id string, err error) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	id = ast.NewNodeID()
 	id = ast.NewNodeID()
 	boxLocalPath := filepath.Join(util.DataDir, id)
 	boxLocalPath := filepath.Join(util.DataDir, id)
@@ -54,8 +54,8 @@ func CreateBox(name string) (id string, err error) {
 
 
 func RenameBox(boxID, name string) (err error) {
 func RenameBox(boxID, name string) (err error) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	box := Conf.Box(boxID)
 	box := Conf.Box(boxID)
 	if nil == box {
 	if nil == box {
@@ -72,8 +72,8 @@ func RenameBox(boxID, name string) (err error) {
 
 
 func RemoveBox(boxID string) (err error) {
 func RemoveBox(boxID string) (err error) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	if util.IsReservedFilename(boxID) {
 	if util.IsReservedFilename(boxID) {
 		return errors.New(fmt.Sprintf("can not remove [%s] caused by it is a reserved file", boxID))
 		return errors.New(fmt.Sprintf("can not remove [%s] caused by it is a reserved file", boxID))
@@ -115,8 +115,8 @@ func RemoveBox(boxID string) (err error) {
 
 
 func Unmount(boxID string) {
 func Unmount(boxID string) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	unmount0(boxID)
 	unmount0(boxID)
 	evt := util.NewCmdResult("unmount", 0, util.PushModeBroadcast, 0)
 	evt := util.NewCmdResult("unmount", 0, util.PushModeBroadcast, 0)
@@ -141,8 +141,8 @@ func unmount0(boxID string) {
 
 
 func Mount(boxID string) (alreadyMount bool, err error) {
 func Mount(boxID string) (alreadyMount bool, err error) {
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	syncLock.Lock()
-	defer syncLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 
 
 	localPath := filepath.Join(util.DataDir, boxID)
 	localPath := filepath.Join(util.DataDir, boxID)
 
 

+ 7 - 7
kernel/model/sync.go

@@ -73,9 +73,6 @@ func SyncData(boot, exit, byHand bool) {
 		return
 		return
 	}
 	}
 
 
-	syncLock.Lock()
-	defer syncLock.Unlock()
-
 	if boot {
 	if boot {
 		util.IncBootProgress(3, "Syncing data from the cloud...")
 		util.IncBootProgress(3, "Syncing data from the cloud...")
 		BootSyncSucc = 0
 		BootSyncSucc = 0
@@ -127,8 +124,11 @@ func SyncData(boot, exit, byHand bool) {
 		util.BroadcastByType("main", "syncing", 1, msg, nil)
 		util.BroadcastByType("main", "syncing", 1, msg, nil)
 	}()
 	}()
 
 
+	syncLock.Lock()
+	defer syncLock.Unlock()
+
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-	writingTreeLock.Lock()
+	writingDataLock.Lock()
 	var err error
 	var err error
 	// 将 data 变更同步到 sync
 	// 将 data 变更同步到 sync
 	if err = workspaceData2SyncDir(); nil != err {
 	if err = workspaceData2SyncDir(); nil != err {
@@ -141,7 +141,7 @@ func SyncData(boot, exit, byHand bool) {
 		if exit {
 		if exit {
 			ExitSyncSucc = 1
 			ExitSyncSucc = 1
 		}
 		}
-		writingTreeLock.Unlock()
+		writingDataLock.Unlock()
 		return
 		return
 	}
 	}
 
 
@@ -156,10 +156,10 @@ func SyncData(boot, exit, byHand bool) {
 		if exit {
 		if exit {
 			ExitSyncSucc = 1
 			ExitSyncSucc = 1
 		}
 		}
-		writingTreeLock.Unlock()
+		writingDataLock.Unlock()
 		return
 		return
 	}
 	}
-	writingTreeLock.Unlock()
+	writingDataLock.Unlock()
 
 
 	cloudSyncVer, err := getCloudSyncVer(Conf.Sync.CloudName)
 	cloudSyncVer, err := getCloudSyncVer(Conf.Sync.CloudName)
 	if nil != err {
 	if nil != err {

+ 3 - 3
kernel/model/transaction.go

@@ -43,7 +43,7 @@ var (
 	ErrNotFullyBoot = errors.New("the kernel has not been fully booted, please try again later")
 	ErrNotFullyBoot = errors.New("the kernel has not been fully booted, please try again later")
 )
 )
 
 
-var writingTreeLock = sync.Mutex{}
+var writingDataLock = sync.Mutex{}
 
 
 func IsFoldHeading(transactions *[]*Transaction) bool {
 func IsFoldHeading(transactions *[]*Transaction) bool {
 	if 1 == len(*transactions) && 1 == len((*transactions)[0].DoOperations) {
 	if 1 == len(*transactions) && 1 == len((*transactions)[0].DoOperations) {
@@ -114,8 +114,8 @@ func AutoFlushTx() {
 }
 }
 
 
 func flushTx() {
 func flushTx() {
-	writingTreeLock.Lock()
-	defer writingTreeLock.Unlock()
+	writingDataLock.Lock()
+	defer writingDataLock.Unlock()
 	defer util.Recover()
 	defer util.Recover()
 
 
 	currentTx = mergeTx()
 	currentTx = mergeTx()