diff --git a/src/services/wiki/index.ts b/src/services/wiki/index.ts index 9a650b18..d715a4fd 100644 --- a/src/services/wiki/index.ts +++ b/src/services/wiki/index.ts @@ -3,7 +3,7 @@ import { createWorkerProxy, terminateWorker } from '@services/libs/workerAdapter import { dialog, shell } from 'electron'; import { attachWorker } from 'electron-ipc-cat/server'; import { backOff } from 'exponential-backoff'; -import { copy, createSymlink, exists, mkdir, mkdirp, mkdirs, pathExists, readdir, readFile, remove } from 'fs-extra'; +import { copy, exists, mkdir, mkdirs, pathExists, readdir, readFile } from 'fs-extra'; import { inject, injectable } from 'inversify'; import path from 'path'; import { Worker } from 'worker_threads'; @@ -430,31 +430,6 @@ export class Wiki implements IWikiService { logger.info(message, { handler: WikiChannel.createProgress }); }; - private readonly folderToContainSymlinks = 'subwiki'; - /** - * Link a sub wiki to a main wiki, this will create a shortcut folder from main wiki to sub wiki, so when saving files to that shortcut folder, you will actually save file to the sub wiki - * We place symbol-link (short-cuts) in the tiddlers/subwiki/ folder, and ignore this folder in the .gitignore, so this symlink won't be commit to the git, as it contains computer specific path. - * @param {string} mainWikiPath folderPath of a wiki as link's destination - * @param {string} folderName sub-wiki's folder name - * @param {string} newWikiPath sub-wiki's folder path - */ - public async linkWiki(mainWikiPath: string, folderName: string, subWikiPath: string): Promise { - const mainWikiTiddlersFolderSubWikisPath = path.join(mainWikiPath, TIDDLERS_PATH, this.folderToContainSymlinks); - const subwikiSymlinkPath = path.join(mainWikiTiddlersFolderSubWikisPath, folderName); - try { - try { - await remove(subwikiSymlinkPath); - } catch (_error: unknown) { - void _error; - } - await mkdirp(mainWikiTiddlersFolderSubWikisPath); - await createSymlink(subWikiPath, subwikiSymlinkPath, 'junction'); - this.logProgress(i18n.t('AddWorkspace.CreateLinkFromSubWikiToMainWikiSucceed')); - } catch (error: unknown) { - throw new Error(i18n.t('AddWorkspace.CreateLinkFromSubWikiToMainWikiFailed', { subWikiPath, mainWikiTiddlersFolderPath: subwikiSymlinkPath, error })); - } - } - private async createWiki(newFolderPath: string, folderName: string): Promise { this.logProgress(i18n.t('AddWorkspace.StartUsingTemplateToCreateWiki')); const newWikiPath = path.join(newFolderPath, folderName); @@ -487,7 +462,7 @@ export class Wiki implements IWikiService { this.logProgress(i18n.t('AddWorkspace.WikiTemplateCopyCompleted') + newWikiPath); } - public async createSubWiki(parentFolderLocation: string, folderName: string, _subWikiFolderName: string, mainWikiPath: string, _tagName = '', onlyLink = false): Promise { + public async createSubWiki(parentFolderLocation: string, folderName: string, _subWikiFolderName: string, _mainWikiPath: string, _tagName = '', onlyLink = false): Promise { this.logProgress(i18n.t('AddWorkspace.StartCreatingSubWiki')); const newWikiPath = path.join(parentFolderLocation, folderName); if (!(await pathExists(parentFolderLocation))) { @@ -503,22 +478,15 @@ export class Wiki implements IWikiService { throw new Error(i18n.t('AddWorkspace.CantCreateFolderHere', { newWikiPath })); } } - this.logProgress(i18n.t('AddWorkspace.StartLinkingSubWikiToMainWiki')); - await this.linkWiki(mainWikiPath, folderName, newWikiPath); // Sub-wiki configuration is now handled by FileSystemAdaptor in watch-filesystem plugin - // No need to update $:/config/FileSystemPaths manually - + // No need to update $:/config/FileSystemPaths manually or create symlinks this.logProgress(i18n.t('AddWorkspace.SubWikiCreationCompleted')); } - public async removeWiki(wikiPath: string, mainWikiToUnLink?: string, onlyRemoveLink = false): Promise { - if (mainWikiToUnLink !== undefined) { - const subWikiName = path.basename(wikiPath); - await shell.trashItem(path.join(mainWikiToUnLink, TIDDLERS_PATH, this.folderToContainSymlinks, subWikiName)); - } - if (!onlyRemoveLink) { - await shell.trashItem(wikiPath); - } + public async removeWiki(wikiPath: string, _mainWikiToUnLink?: string, _onlyRemoveLink = false): Promise { + // Sub-wiki configuration is now handled by FileSystemAdaptor - no symlinks to manage + // Just remove the wiki folder itself + await shell.trashItem(wikiPath); } public async ensureWikiExist(wikiPath: string, shouldBeMainWiki: boolean): Promise { @@ -640,7 +608,7 @@ export class Wiki implements IWikiService { public async cloneSubWiki( parentFolderLocation: string, wikiFolderName: string, - mainWikiPath: string, + _mainWikiPath: string, gitRepoUrl: string, gitUserInfo: IGitUserInfos, _tagName = '', @@ -660,10 +628,8 @@ export class Wiki implements IWikiService { } const gitService = container.get(serviceIdentifier.Git); await gitService.clone(gitRepoUrl, path.join(parentFolderLocation, wikiFolderName), gitUserInfo); - this.logProgress(i18n.t('AddWorkspace.StartLinkingSubWikiToMainWiki')); - await this.linkWiki(mainWikiPath, wikiFolderName, path.join(parentFolderLocation, wikiFolderName)); // Sub-wiki configuration is now handled by FileSystemAdaptor in watch-filesystem plugin - // No need to update $:/config/FileSystemPaths manually + // No need to update $:/config/FileSystemPaths manually or create symlinks } // wiki-startup.ts diff --git a/src/services/wiki/interface.ts b/src/services/wiki/interface.ts index 74ba0924..ba8463a2 100644 --- a/src/services/wiki/interface.ts +++ b/src/services/wiki/interface.ts @@ -60,7 +60,6 @@ export interface IWikiService { * @param workspaceID You can get this from active workspace */ getWorker(workspaceID: string): WikiWorker | undefined; - linkWiki(mainWikiPath: string, folderName: string, subWikiPath: string): Promise; packetHTMLFromWikiFolder(wikiFolderLocation: string, pathOfNewHTML: string): Promise; removeWiki(wikiPath: string, mainWikiToUnLink?: string, onlyRemoveLink?: boolean): Promise; restartWiki(workspace: IWorkspace): Promise; @@ -110,7 +109,6 @@ export const WikiServiceIPCDescriptor = { ensureWikiExist: ProxyPropertyType.Function, extractWikiHTML: ProxyPropertyType.Function, getWikiErrorLogs: ProxyPropertyType.Function, - linkWiki: ProxyPropertyType.Function, getTiddlerFilePath: ProxyPropertyType.Function, packetHTMLFromWikiFolder: ProxyPropertyType.Function, removeWiki: ProxyPropertyType.Function,