diff --git a/localization/locales/en/translation.json b/localization/locales/en/translation.json index 0cb5bcb4..e61c4ce4 100644 --- a/localization/locales/en/translation.json +++ b/localization/locales/en/translation.json @@ -249,8 +249,10 @@ "OpenMetaDataFolderDetail": "TiddlyWiki's data and TiddlyGit's workspace metadata are stored separately. TiddlyGit's metadata includes workspace settings, etc., which are stored in this folder in JSON format." }, "Error": { - "InitWikiGitError": "Note warehouse initialization failed error", - "InitWikiGitErrorDescription": "The template used by the new note repository failed to copy or the git initialization of the note repository failed. This should be a bug." + "InitWikiGitError": "InitWikiGitError", + "InitWikiGitErrorDescription": "The template used by the new note repository failed to copy or the git initialization of the note repository failed. This should be a bug.", + "InitWikiGitRevertError": "InitWikiGitRevertError", + "InitWikiGitRevertErrorDescription": "Not only did the initialization of the note warehouse fail, but also the revocation failed. This is a serious problem, and you need to manually clean up the new folder generated in this location." }, "Loading": "Loading", "Yes": "Yes", diff --git a/localization/locales/zh_CN/translation.json b/localization/locales/zh_CN/translation.json index 4ca905e6..d933b83d 100644 --- a/localization/locales/zh_CN/translation.json +++ b/localization/locales/zh_CN/translation.json @@ -251,7 +251,9 @@ }, "Error": { "InitWikiGitError": "笔记仓库初始化失败错误", - "InitWikiGitErrorDescription": "新笔记仓库所用的模板复制失败或者笔记仓库的git初始化失败,这应该是个bug。" + "InitWikiGitErrorDescription": "新笔记仓库所用的模板复制失败或者笔记仓库的git初始化失败,这应该是个bug。", + "InitWikiGitRevertError": "笔记仓库初始化失败且撤销失败错误", + "InitWikiGitRevertErrorDescription": "不仅笔记仓库初始化失败了,而且撤销也失败了,这是个严重问题,需要你手动清理该位置生成的新文件夹。" }, "Loading": "加载中", "Yes": "是的", diff --git a/src/services/wikiGitWorkspace/error.ts b/src/services/wikiGitWorkspace/error.ts index f3547fc8..f9fffa2d 100644 --- a/src/services/wikiGitWorkspace/error.ts +++ b/src/services/wikiGitWorkspace/error.ts @@ -7,3 +7,11 @@ export class InitWikiGitError extends Error { this.message = `${i18n.t('Error.InitWikiGitErrorDescription')} ${extraMessage ?? ''}`; } } + +export class InitWikiGitRevertError extends Error { + constructor(extraMessage?: string) { + super(extraMessage); + this.name = i18n.t('Error.InitWikiGitRevertError'); + this.message = `${i18n.t('Error.InitWikiGitRevertErrorDescription')} ${extraMessage ?? ''}`; + } +} diff --git a/src/services/wikiGitWorkspace/index.ts b/src/services/wikiGitWorkspace/index.ts index fda63cec..cf0cc0d5 100644 --- a/src/services/wikiGitWorkspace/index.ts +++ b/src/services/wikiGitWorkspace/index.ts @@ -16,7 +16,7 @@ import { logger } from '@services/libs/log'; import i18n from '@services/libs/i18n'; import { IWikiGitWorkspaceService } from './interface'; import { IMenuService } from '@services/menu/interface'; -import { InitWikiGitError } from './error'; +import { InitWikiGitError, InitWikiGitRevertError } from './error'; @injectable() export class WikiGitWorkspace implements IWikiGitWorkspaceService { @@ -50,10 +50,14 @@ export class WikiGitWorkspace implements IWikiGitWorkspaceService { } } catch (error) { logger.info(error); - if (isMainWiki) { - await this.wikiService.removeWiki(wikiFolderPath); - } else { - await this.wikiService.removeWiki(wikiFolderPath, isSyncedWiki ? mainWikiToUnLink : githubRepoUrlOrMainWikiToUnLinkOverload); + try { + if (isMainWiki) { + await this.wikiService.removeWiki(wikiFolderPath); + } else { + await this.wikiService.removeWiki(wikiFolderPath, isSyncedWiki ? mainWikiToUnLink : githubRepoUrlOrMainWikiToUnLinkOverload); + } + } catch (error_) { + throw new InitWikiGitRevertError((error_ as Error).message); } throw new InitWikiGitError((error as Error).message); }