fix: cannot be published successfully after post or single page unpublished (#2762)

#### What type of PR is this?
/kind bug
/area core
/milestone 2.0.0-rc.1

#### What this PR does / why we need it:
修复文章和自定义页面取消发布后无法再继续发布的问题

#### Special notes for yourd reviewer:
how to test it?
1. create a post and publsih it
2. unpublish it then republish
3. excepted to b published successfully

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
None
```
pull/2763/head v2.0.0-rc.1
guqing 2022-11-24 22:53:06 +08:00 committed by GitHub
parent 12fd77f61f
commit 16e4e46e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -104,8 +104,10 @@ public class PostReconciler implements Reconciler<Reconciler.Request> {
if (StringUtils.isBlank(releaseSnapshot)) { if (StringUtils.isBlank(releaseSnapshot)) {
return; return;
} }
// do nothing if release snapshot is not changed
if (StringUtils.equals(lastReleasedSnapshot, releaseSnapshot)) { // do nothing if release snapshot is not changed and post is published
if (post.isPublished()
&& StringUtils.equals(lastReleasedSnapshot, releaseSnapshot)) {
return; return;
} }
Post.PostStatus status = post.getStatusOrDefault(); Post.PostStatus status = post.getStatusOrDefault();

View File

@ -108,8 +108,9 @@ public class SinglePageReconciler implements Reconciler<Reconciler.Request> {
if (StringUtils.isBlank(releaseSnapshot)) { if (StringUtils.isBlank(releaseSnapshot)) {
return; return;
} }
// do nothing if release snapshot is not changed // do nothing if release snapshot is not changed and page is published
if (StringUtils.equals(lastReleasedSnapshot, releaseSnapshot)) { if (page.isPublished()
&& StringUtils.equals(lastReleasedSnapshot, releaseSnapshot)) {
return; return;
} }
SinglePage.SinglePageStatus status = page.getStatusOrDefault(); SinglePage.SinglePageStatus status = page.getStatusOrDefault();