From 106a11b4df9ae064dacf5d429b13af6f017e13d6 Mon Sep 17 00:00:00 2001 From: dudu Date: Sun, 6 Oct 2024 12:03:30 +0800 Subject: [PATCH] fix: use chinese hash in filename --- package-lock.json | 4 ++-- package.json | 2 +- src/cmd/post-list/post-pull.ts | 3 +++ src/service/post/post-file-map.ts | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0b59dbb5..067ae984 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-cnb", - "version": "0.0.1", + "version": "1.8.58", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-cnb", - "version": "0.0.1", + "version": "1.8.58", "license": "LICENSE.txt", "dependencies": { "@cnblogs/code-quality": "^2.0.2", diff --git a/package.json b/package.json index 244b3201..75f877d8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-cnb", "displayName": "博客园 cnblogs 客户端", "description": "Cnblogs Client For VSCode", - "version": "0.0.1", + "version": "1.8.58", "license": "LICENSE.txt", "preview": false, "publisher": "cnblogs", diff --git a/src/cmd/post-list/post-pull.ts b/src/cmd/post-list/post-pull.ts index 71c202d4..3a60abd6 100644 --- a/src/cmd/post-list/post-pull.ts +++ b/src/cmd/post-list/post-pull.ts @@ -45,6 +45,9 @@ export async function postPull(input: InputType, showConfirm = true, mute = fals } let uriPath = PostFileMapManager.getFilePath(post.id) + + if (uriPath != null && uriPath.indexOf('#') < 0 && post.title.indexOf('#') >= 0) uriPath = undefined + let fileUri: Uri if (uriPath == null) { fileUri = PostFileMapManager.buildLocalPostFileUri(post) diff --git a/src/service/post/post-file-map.ts b/src/service/post/post-file-map.ts index 67046ad1..02ce27ff 100644 --- a/src/service/post/post-file-map.ts +++ b/src/service/post/post-file-map.ts @@ -29,7 +29,8 @@ export namespace PostFileMapManager { export function buildLocalPostFileUri(post: Post, appendToFileName = ''): Uri { const workspaceUri = WorkspaceCfg.getWorkspaceUri() const ext = `${post.isMarkdown ? 'md' : 'html'}` - let postTitle = sanitizeFileName(post.title) + let postTitle = post.title.replace(/#/g, '#') + postTitle = sanitizeFileName(postTitle) if (/\.\d+$/.test(postTitle)) postTitle += '_' return Uri.joinPath(workspaceUri, `${postTitle}${appendToFileName}.${post.id}.${ext}`) }