Formatting fix?
This commit is contained in:
@@ -79,16 +79,17 @@ type wikiDeployManifest struct {
|
||||
}
|
||||
|
||||
type wikiDeployManifestPage struct {
|
||||
Hash string `json:"hash"`
|
||||
LastSeenHash string `json:"last_seen_hash,omitempty"`
|
||||
ArchivedHash string `json:"archived_hash,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
TopicTitle string `json:"topic_title,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Stale bool `json:"stale,omitempty"`
|
||||
TID int `json:"tid,omitempty"`
|
||||
PID int `json:"pid,omitempty"`
|
||||
CID int `json:"cid,omitempty"`
|
||||
Hash string `json:"hash"`
|
||||
LastSeenHash string `json:"last_seen_hash,omitempty"`
|
||||
ArchivedHash string `json:"archived_hash,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
TopicTitle string `json:"topic_title,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Stale bool `json:"stale,omitempty"`
|
||||
SourceContentSynced bool `json:"source_content_synced,omitempty"`
|
||||
TID int `json:"tid,omitempty"`
|
||||
PID int `json:"pid,omitempty"`
|
||||
CID int `json:"cid,omitempty"`
|
||||
}
|
||||
|
||||
type wikiDeployPlan struct {
|
||||
@@ -541,6 +542,8 @@ func planNodeBBDeploy(pages map[string]wikiDeployPage, manifest wikiDeployManife
|
||||
}
|
||||
result.Created++
|
||||
page.Title = entry.TopicTitle
|
||||
entry.SourceContentSynced = true
|
||||
next.Pages[pageID] = entry
|
||||
plans = append(plans, wikiDeployPlan{Page: page, Entry: entry, Action: "create", Content: page.Content})
|
||||
continue
|
||||
}
|
||||
@@ -556,7 +559,8 @@ func planNodeBBDeploy(pages map[string]wikiDeployPage, manifest wikiDeployManife
|
||||
}
|
||||
}
|
||||
|
||||
if manifest.Pages[pageID].Hash == page.Hash {
|
||||
needsSourceContentSync := !manifest.Pages[pageID].SourceContentSynced
|
||||
if manifest.Pages[pageID].Hash == page.Hash && !needsSourceContentSync {
|
||||
result.Skipped++
|
||||
continue
|
||||
}
|
||||
@@ -588,6 +592,8 @@ func planNodeBBDeploy(pages map[string]wikiDeployPage, manifest wikiDeployManife
|
||||
}
|
||||
result.Created++
|
||||
page.Title = entry.TopicTitle
|
||||
entry.SourceContentSynced = true
|
||||
next.Pages[pageID] = entry
|
||||
plans = append(plans, wikiDeployPlan{Page: page, Entry: entry, Action: "create", Content: page.Content})
|
||||
continue
|
||||
}
|
||||
@@ -608,11 +614,13 @@ func planNodeBBDeploy(pages map[string]wikiDeployPage, manifest wikiDeployManife
|
||||
}
|
||||
}
|
||||
merged := mergeManagedContent(remote.Content, page.Content)
|
||||
if merged == remote.Content {
|
||||
if merged == remote.Content && !needsSourceContentSync {
|
||||
result.Skipped++
|
||||
continue
|
||||
}
|
||||
result.Updated++
|
||||
entry.SourceContentSynced = true
|
||||
next.Pages[pageID] = entry
|
||||
plans = append(plans, wikiDeployPlan{Page: page, Entry: entry, Action: "update", Content: merged, RemoteHash: remoteHash})
|
||||
}
|
||||
for pageID := range manifest.Pages {
|
||||
@@ -636,6 +644,7 @@ func planNodeBBDeploy(pages map[string]wikiDeployPage, manifest wikiDeployManife
|
||||
body := renderArchivedWikiPage(pageID, entry.Title)
|
||||
entry.Hash = computeManagedHash(body)
|
||||
entry.ArchivedHash = entry.Hash
|
||||
entry.SourceContentSynced = true
|
||||
next.Pages[pageID] = entry
|
||||
result.Archived++
|
||||
plans = append(plans, wikiDeployPlan{
|
||||
@@ -759,6 +768,7 @@ func recoverCreateCollision(plan wikiDeployPlan, manifest wikiDeployManifest, cl
|
||||
entry.TopicTitle = plan.Entry.TopicTitle
|
||||
entry.Namespace = plan.Entry.Namespace
|
||||
entry.Stale = false
|
||||
entry.SourceContentSynced = true
|
||||
manifest.Pages[plan.Page.PageID] = entry
|
||||
return true, nil
|
||||
}
|
||||
@@ -1369,10 +1379,11 @@ func isNodeBBMissingResource(err error) bool {
|
||||
}
|
||||
|
||||
type nodeBBPost struct {
|
||||
PID int
|
||||
TID int
|
||||
Title string
|
||||
Content string
|
||||
PID int
|
||||
TID int
|
||||
Title string
|
||||
Content string
|
||||
SourceContent string
|
||||
}
|
||||
|
||||
type nodeBBEditLock struct {
|
||||
@@ -1457,7 +1468,7 @@ func (c *nodeBBClient) listNamespacePagesWithQuery(cid int, query string) ([]nod
|
||||
}
|
||||
|
||||
func (c *nodeBBClient) createTopic(cid int, title, content, summary string) (nodeBBPost, error) {
|
||||
body := map[string]any{"cid": cid, "title": title, "content": content}
|
||||
body := map[string]any{"cid": cid, "title": title, "content": content, "sourceContent": content}
|
||||
if summary != "" {
|
||||
body["_uid_note"] = summary
|
||||
}
|
||||
@@ -1484,7 +1495,7 @@ func (c *nodeBBClient) updatePost(tid, pid int, content, summary string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
body := map[string]any{"content": content}
|
||||
body := map[string]any{"content": content, "sourceContent": content}
|
||||
if lock.Token != "" {
|
||||
body["wikiEditLockToken"] = lock.Token
|
||||
}
|
||||
@@ -1597,11 +1608,17 @@ func parseNodeBBPost(doc any) nodeBBPost {
|
||||
}
|
||||
return post
|
||||
}
|
||||
sourceContent := firstString(m, "sourceContent", "source_content")
|
||||
content := firstString(m, "content")
|
||||
if sourceContent != "" {
|
||||
content = sourceContent
|
||||
}
|
||||
return nodeBBPost{
|
||||
PID: firstInt(m, "pid", "mainPid"),
|
||||
TID: firstInt(m, "tid"),
|
||||
Title: firstString(m, "title", "titleRaw", "title_raw"),
|
||||
Content: firstString(m, "content"),
|
||||
PID: firstInt(m, "pid", "mainPid"),
|
||||
TID: firstInt(m, "tid"),
|
||||
Title: firstString(m, "title", "titleRaw", "title_raw"),
|
||||
Content: content,
|
||||
SourceContent: sourceContent,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user