From 16e4e46e4041be5689842173d5911cefed738db6 Mon Sep 17 00:00:00 2001 From: guqing <38999863+guqing@users.noreply.github.com> Date: Thu, 24 Nov 2022 22:53:06 +0800 Subject: [PATCH] fix: cannot be published successfully after post or single page unpublished (#2762) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### 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 ``` --- .../halo/app/core/extension/reconciler/PostReconciler.java | 6 ++++-- .../app/core/extension/reconciler/SinglePageReconciler.java | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java b/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java index e79ecea72..595552bfe 100644 --- a/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java +++ b/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java @@ -104,8 +104,10 @@ public class PostReconciler implements Reconciler { if (StringUtils.isBlank(releaseSnapshot)) { 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; } Post.PostStatus status = post.getStatusOrDefault(); diff --git a/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java b/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java index d02f98e14..9709c5615 100644 --- a/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java +++ b/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java @@ -108,8 +108,9 @@ public class SinglePageReconciler implements Reconciler { if (StringUtils.isBlank(releaseSnapshot)) { return; } - // do nothing if release snapshot is not changed - if (StringUtils.equals(lastReleasedSnapshot, releaseSnapshot)) { + // do nothing if release snapshot is not changed and page is published + if (page.isPublished() + && StringUtils.equals(lastReleasedSnapshot, releaseSnapshot)) { return; } SinglePage.SinglePageStatus status = page.getStatusOrDefault();