Added fallback if renaming cant move an upload

This commit is contained in:
Leon Mika 2026-03-05 22:48:38 +11:00
parent 891d904d9c
commit 76ed54f119
3 changed files with 40 additions and 4 deletions

View file

@ -17,6 +17,8 @@ type CreatePostParams struct {
}
func (s *Service) UpdatePost(ctx context.Context, params CreatePostParams) (*models.Post, error) {
now := time.Now()
site, ok := models.GetSite(ctx)
if !ok {
return nil, models.SiteRequiredError
@ -29,14 +31,14 @@ func (s *Service) UpdatePost(ctx context.Context, params CreatePostParams) (*mod
post.Title = params.Title
post.Body = params.Body
post.UpdatedAt = time.Now()
post.UpdatedAt = now
post.Slug = post.BestSlug()
oldState := post.State
switch strings.ToLower(params.Action) {
case "publish":
post.State = models.StatePublished
post.PublishedAt = time.Now()
post.PublishedAt = now
case "save draft":
post.State = models.StateDraft
post.PublishedAt = time.Time{}