Deploy cursor fix?
This commit is contained in:
@@ -528,11 +528,11 @@ func planNodeBBDeploy(pages map[string]wikiDeployPage, manifest wikiDeployManife
|
||||
}
|
||||
|
||||
if entry.TID != 0 && entry.CID != 0 && shouldCheckRemoteTopicTitle(manifest.Pages[pageID], page.Title, entry.TopicTitle, opts.TitlePrefixMinLength) {
|
||||
remotePage, ok, err := findMappedRemotePage(entry, remotePagesByCID, client, progress)
|
||||
remoteTopic, ok, err := findMappedRemoteTopic(entry, client)
|
||||
if err != nil {
|
||||
return nil, result, next, err
|
||||
}
|
||||
if ok && titleNeedsRename(remotePageTitle(remotePage), entry.TopicTitle) {
|
||||
if ok && titleNeedsRename(remoteTopic.Title, entry.TopicTitle) {
|
||||
result.Renamed++
|
||||
plans = append(plans, wikiDeployPlan{Page: page, Entry: entry, Action: "rename", Title: entry.TopicTitle})
|
||||
}
|
||||
@@ -690,30 +690,15 @@ func planManagedNamespaceReset(opts DeployWikiOptions, client *nodeBBClient, pro
|
||||
return plans, len(plans), nil
|
||||
}
|
||||
|
||||
func findMappedRemotePage(entry wikiDeployManifestPage, remotePagesByCID map[int][]nodeBBWikiPage, client *nodeBBClient, progress func(string)) (nodeBBWikiPage, bool, error) {
|
||||
remotePages, ok := remotePagesByCID[entry.CID]
|
||||
if !ok {
|
||||
var err error
|
||||
progress(fmt.Sprintf("Listing NodeBB wiki namespace category %d", entry.CID))
|
||||
remotePages, err = client.listNamespacePages(entry.CID)
|
||||
if err != nil {
|
||||
return nodeBBWikiPage{}, false, err
|
||||
func findMappedRemoteTopic(entry wikiDeployManifestPage, client *nodeBBClient) (nodeBBPost, bool, error) {
|
||||
topic, err := client.getTopic(entry.TID)
|
||||
if err != nil {
|
||||
if isNodeBBMissingResource(err) {
|
||||
return nodeBBPost{}, false, nil
|
||||
}
|
||||
remotePagesByCID[entry.CID] = remotePages
|
||||
return nodeBBPost{}, false, err
|
||||
}
|
||||
for _, remotePage := range remotePages {
|
||||
if remotePage.TID == entry.TID {
|
||||
return remotePage, true, nil
|
||||
}
|
||||
}
|
||||
return nodeBBWikiPage{}, false, nil
|
||||
}
|
||||
|
||||
func remotePageTitle(page nodeBBWikiPage) string {
|
||||
if title := strings.TrimSpace(page.Title); title != "" {
|
||||
return title
|
||||
}
|
||||
return strings.TrimSpace(page.TitleLeaf)
|
||||
return topic, true, nil
|
||||
}
|
||||
|
||||
func titleNeedsRename(current, desired string) bool {
|
||||
@@ -1364,6 +1349,7 @@ func isNodeBBMissingResource(err error) bool {
|
||||
type nodeBBPost struct {
|
||||
PID int
|
||||
TID int
|
||||
Title string
|
||||
Content string
|
||||
}
|
||||
|
||||
@@ -1581,11 +1567,18 @@ func parseNodeBBPost(doc any) nodeBBPost {
|
||||
if post.TID == 0 {
|
||||
post.TID = intFromAny(m["tid"])
|
||||
}
|
||||
if post.PID == 0 {
|
||||
post.PID = firstInt(m, "mainPid")
|
||||
}
|
||||
if post.Title == "" {
|
||||
post.Title = firstString(m, "title", "titleRaw", "title_raw")
|
||||
}
|
||||
return post
|
||||
}
|
||||
return nodeBBPost{
|
||||
PID: firstInt(m, "pid", "mainPid"),
|
||||
TID: firstInt(m, "tid"),
|
||||
Title: firstString(m, "title", "titleRaw", "title_raw"),
|
||||
Content: firstString(m, "content"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user