فهرست منبع

:art: Improve open/remove notebook

Daniel 1 سال پیش
والد
کامیت
c18b79d374

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

@@ -1457,6 +1457,7 @@
     "235": "[%d/%d] is updating the marketplace package...",
     "235": "[%d/%d] is updating the marketplace package...",
     "236": "[%d/%d] is updating the marketplace package [%s]...",
     "236": "[%d/%d] is updating the marketplace package [%s]...",
     "237": "[%d] marketplace packages have all been updated successfully",
     "237": "[%d] marketplace packages have all been updated successfully",
-    "238": "Marketplace package [%s] update failed, please try again later"
+    "238": "Marketplace package [%s] update failed, please try again later",
+    "239": "Related operations are being processed, please try again later"
   }
   }
 }
 }

+ 2 - 1
app/appearance/langs/es_ES.json

@@ -1457,6 +1457,7 @@
     "235": "[%d/%d] está actualizando el paquete del mercado...",
     "235": "[%d/%d] está actualizando el paquete del mercado...",
     "236": "[%d/%d] está actualizando el paquete del mercado [%s]...",
     "236": "[%d/%d] está actualizando el paquete del mercado [%s]...",
     "237": "[%d] todos los paquetes del mercado se han actualizado correctamente",
     "237": "[%d] todos los paquetes del mercado se han actualizado correctamente",
-    "238": "Error en la actualización del paquete Marketplace [%s], inténtalo de nuevo más tarde"
+    "238": "Error en la actualización del paquete Marketplace [%s], inténtalo de nuevo más tarde",
+    "239": "Las operaciones relacionadas se están procesando, inténtalo de nuevo más tarde"
   }
   }
 }
 }

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

@@ -1457,6 +1457,7 @@
     "235": "[%d/%d] met à jour le package Marketplace...",
     "235": "[%d/%d] met à jour le package Marketplace...",
     "236": "[%d/%d] met à jour le package Marketplace [%s]...",
     "236": "[%d/%d] met à jour le package Marketplace [%s]...",
     "237": "[%d] packages Marketplace ont tous été mis à jour avec succès",
     "237": "[%d] packages Marketplace ont tous été mis à jour avec succès",
-    "238": "La mise à jour du package Marketplace [%s] a échoué, veuillez réessayer plus tard"
+    "238": "La mise à jour du package Marketplace [%s] a échoué, veuillez réessayer plus tard",
+    "239": "Les opérations associées sont en cours de traitement, veuillez réessayer plus tard"
   }
   }
 }
 }

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

@@ -1457,6 +1457,7 @@
     "235": "[%d/%d] 正在更新市集包...",
     "235": "[%d/%d] 正在更新市集包...",
     "236": "[%d/%d] 正在更新市集包 [%s]...",
     "236": "[%d/%d] 正在更新市集包 [%s]...",
     "237": "[%d] 個市集包已經全部更新成功",
     "237": "[%d] 個市集包已經全部更新成功",
-    "238": "市集包 [%s] 更新失敗,請稍後再試"
+    "238": "市集包 [%s] 更新失敗,請稍後再試",
+    "239": "相關操作正在處理中,請稍後再試"
   }
   }
 }
 }

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

@@ -1457,6 +1457,7 @@
     "235": "[%d/%d] 正在更新集市包...",
     "235": "[%d/%d] 正在更新集市包...",
     "236": "[%d/%d] 正在更新集市包 [%s]...",
     "236": "[%d/%d] 正在更新集市包 [%s]...",
     "237": "[%d] 个集市包已经全部更新成功",
     "237": "[%d] 个集市包已经全部更新成功",
-    "238": "集市包 [%s] 更新失败,请稍后再试"
+    "238": "集市包 [%s] 更新失败,请稍后再试",
+    "239": "相关操作正在处理中,请稍后再试"
   }
   }
 }
 }

+ 24 - 4
kernel/model/mount.go

@@ -22,6 +22,7 @@ import (
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"strings"
 	"strings"
+	"sync"
 	"time"
 	"time"
 	"unicode/utf8"
 	"unicode/utf8"
 
 
@@ -88,13 +89,23 @@ func RenameBox(boxID, name string) (err error) {
 	return
 	return
 }
 }
 
 
+var boxLock = sync.Map{}
+
 func RemoveBox(boxID string) (err error) {
 func RemoveBox(boxID string) (err error) {
+	if _, ok := boxLock.Load(boxID); ok {
+		err = fmt.Errorf(Conf.language(239))
+		return
+	}
+
+	boxLock.Store(boxID, true)
+	defer boxLock.Delete(boxID)
+
 	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))
 	}
 	}
 
 
 	WaitForWritingFiles()
 	WaitForWritingFiles()
-
+	isUserGuide := IsUserGuide(boxID)
 	createDocLock.Lock()
 	createDocLock.Lock()
 	defer createDocLock.Unlock()
 	defer createDocLock.Unlock()
 
 
@@ -106,7 +117,7 @@ func RemoveBox(boxID string) (err error) {
 		return errors.New(fmt.Sprintf("can not remove [%s] caused by it is not a dir", boxID))
 		return errors.New(fmt.Sprintf("can not remove [%s] caused by it is not a dir", boxID))
 	}
 	}
 
 
-	if !IsUserGuide(boxID) {
+	if !isUserGuide {
 		var historyDir string
 		var historyDir string
 		historyDir, err = GetHistoryDir(HistoryOpDelete)
 		historyDir, err = GetHistoryDir(HistoryOpDelete)
 		if nil != err {
 		if nil != err {
@@ -155,11 +166,20 @@ func unmount0(boxID string) {
 }
 }
 
 
 func Mount(boxID string) (alreadyMount bool, err error) {
 func Mount(boxID string) (alreadyMount bool, err error) {
+	if _, ok := boxLock.Load(boxID); ok {
+		err = fmt.Errorf(Conf.language(239))
+		return
+	}
+
+	boxLock.Store(boxID, true)
+	defer boxLock.Delete(boxID)
+
 	WaitForWritingFiles()
 	WaitForWritingFiles()
+	isUserGuide := IsUserGuide(boxID)
 
 
 	localPath := filepath.Join(util.DataDir, boxID)
 	localPath := filepath.Join(util.DataDir, boxID)
 	var reMountGuide bool
 	var reMountGuide bool
-	if IsUserGuide(boxID) {
+	if isUserGuide {
 		// 重新挂载帮助文档
 		// 重新挂载帮助文档
 
 
 		guideBox := Conf.Box(boxID)
 		guideBox := Conf.Box(boxID)
@@ -226,7 +246,7 @@ func Mount(boxID string) (alreadyMount bool, err error) {
 	treenode.SaveBlockTree(false)
 	treenode.SaveBlockTree(false)
 	util.ClearPushProgress(100)
 	util.ClearPushProgress(100)
 
 
-	if IsUserGuide(boxID) {
+	if isUserGuide {
 		go func() {
 		go func() {
 			var startID string
 			var startID string
 			i := 0
 			i := 0