云端数据同步时降低交互阻塞时间 Fix https://github.com/siyuan-note/siyuan/issues/4984

This commit is contained in:
Liang Ding 2022-05-30 10:50:12 +08:00
parent 1cdc80e1bd
commit c88bd514d3
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
10 changed files with 63 additions and 91 deletions

View file

@ -50,8 +50,8 @@ func BazaarWidgets() (widgets []*bazaar.Widget) {
}
func InstallBazaarWidget(repoURL, repoHash, widgetName string) error {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
installPath := filepath.Join(util.DataDir, "widgets", widgetName)
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 {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
installPath := filepath.Join(util.DataDir, "widgets", widgetName)
err := bazaar.UninstallWidget(installPath)
@ -92,8 +92,8 @@ func BazaarIcons() (icons []*bazaar.Icon) {
}
func InstallBazaarIcon(repoURL, repoHash, iconName string) error {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
installPath := filepath.Join(util.IconsPath, iconName)
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 {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
installPath := filepath.Join(util.IconsPath, iconName)
err := bazaar.UninstallIcon(installPath)
@ -139,8 +139,8 @@ func BazaarThemes() (ret []*bazaar.Theme) {
}
func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bool) error {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
closeThemeWatchers()
@ -167,8 +167,8 @@ func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bo
}
func UninstallBazaarTheme(themeName string) error {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
closeThemeWatchers()
@ -198,8 +198,8 @@ func BazaarTemplates() (templates []*bazaar.Template) {
}
func InstallBazaarTemplate(repoURL, repoHash, templateName string) error {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
installPath := filepath.Join(util.DataDir, "templates", templateName)
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 {
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
installPath := filepath.Join(util.DataDir, "templates", templateName)
err := bazaar.UninstallTemplate(installPath)