Skip to content

Commit

Permalink
[release-2.10] refactor: autofill if post is published but no publish…
Browse files Browse the repository at this point in the history
… time (#4781)

This is an automated cherry-pick of #4775

/assign ruibaby

```release-note
修复文章可能因为没有发布时间导致发布失败的问题。
```
  • Loading branch information
halo-dev-bot authored Oct 27, 2023
1 parent 19e3e7c commit 2070548
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public Result reconcile(Request request) {
post.setStatus(status);
}

if (post.isPublished() && post.getSpec().getPublishTime() == null) {
post.getSpec().setPublishTime(Instant.now());
}

// calculate the sha256sum
var configSha256sum = Hashing.sha256().hashString(post.getSpec().toString(), UTF_8)
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ void subscribeNewCommentNotification(SinglePage page) {

private void reconcileSpec(String name) {
client.fetch(SinglePage.class, name).ifPresent(page -> {
if (page.isPublished() && page.getSpec().getPublishTime() == null) {
page.getSpec().setPublishTime(Instant.now());
}

// un-publish if necessary
if (page.isPublished() && Objects.equals(false, page.getSpec().getPublish())) {
unPublish(name);
Expand Down

0 comments on commit 2070548

Please sign in to comment.