Skip to content

Commit 7abfa45

Browse files
authored
Merge pull request #215 from cnblogs/fix-upload-post-not-working
fix: upload post not working
2 parents ca5f55b + ec1bf3e commit 7abfa45

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ export async function saveLocalPost(localPost: LocalPost) {
7474
// TODO: need refactor
7575
const autoExtractImgSrc = MarkdownCfg.getAutoExtractImgSrc()
7676
const fileDir = dirname(localPost.filePath)
77+
postToSave.postBody = text
7778
if (autoExtractImgSrc !== undefined) {
7879
const extracted = await extractImg(text, fileDir, autoExtractImgSrc)
7980
if (extracted !== undefined) {
8081
postToSave.postBody = extracted
81-
if (isEmptyBody(text, '(发生于提取图片后')) return false
82+
if (isEmptyBody(postToSave.postBody, '(发生于提取图片后')) return false
8283

8384
if (MarkdownCfg.getApplyAutoExtractImgToLocal()) {
8485
const doc = window.visibleTextEditors.find(x => x.document.uri.fsPath === localPost.filePath)
@@ -89,8 +90,6 @@ export async function saveLocalPost(localPost: LocalPost) {
8990
}
9091
}
9192
}
92-
} else {
93-
postToSave.postBody = text
9493
}
9594

9695
return true
@@ -133,10 +132,12 @@ export async function uploadPost(input?: Post | PostTreeItem | PostEditDto, conf
133132
const text = await localPost.readAllText()
134133
const autoExtractImgSrc = MarkdownCfg.getAutoExtractImgSrc()
135134
const fileDir = dirname(localPost.filePath)
135+
post.postBody = text
136136
if (autoExtractImgSrc !== undefined) {
137137
const extracted = await extractImg(text, fileDir, autoExtractImgSrc)
138138
if (extracted !== undefined) {
139139
post.postBody = extracted
140+
if (isEmptyBody(post.postBody, '(发生于提取图片后')) return false
140141

141142
if (MarkdownCfg.getApplyAutoExtractImgToLocal()) {
142143
const doc = window.visibleTextEditors.find(x => x.document.uri.fsPath === localPost.filePath)?.document
@@ -146,8 +147,6 @@ export async function uploadPost(input?: Post | PostTreeItem | PostEditDto, conf
146147
}
147148
}
148149
}
149-
} else {
150-
post.postBody = text
151150
}
152151

153152
if (isEmptyBody(post.postBody)) return false

0 commit comments

Comments
 (0)