Skip to content

Commit b8afa4a

Browse files
authored
Merge pull request #228 from cnblogs/fix-pull-post-file-path
fix: file path check for post-pull
2 parents 25d17b8 + 98f19ae commit b8afa4a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/cmd/post-list/post-pull.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { revealPostListItem } from '@/service/post/post-list-view'
99
import { PostTreeItem } from '@/tree-view/model/post-tree-item'
1010
import { MarkdownCfg } from '@/ctx/cfg/markdown'
1111
import { fsUtil } from '@/infra/fs/fsUtil'
12+
import { WorkspaceCfg } from '@/ctx/cfg/workspace'
1213

1314
export async function postPull(input: Post | PostTreeItem | Uri | undefined | null, showConfirm = true, mute = false) {
1415
const ctxList: CmdCtx[] = []
@@ -17,7 +18,11 @@ export async function postPull(input: Post | PostTreeItem | Uri | undefined | nu
1718
if (parsePostInput(input) && input.id > 0) {
1819
const post = input
1920
const path = PostFileMapManager.getFilePath(post.id)
20-
if (path === undefined || !(await fsUtil.exists(path))) {
21+
if (
22+
path === undefined ||
23+
!(await fsUtil.exists(path)) ||
24+
path.indexOf(WorkspaceCfg.getWorkspaceUri().path) < 0
25+
) {
2126
isFreshPull = true
2227
const uri = await buildLocalPostFileUri(post, false)
2328
await workspace.fs.writeFile(uri, Buffer.from(post.postBody))

0 commit comments

Comments
 (0)