]> BookStack Code Mirror - api-scripts/blobdiff - go-export-page-content/export.go
Added bsfs to community project list
[api-scripts] / go-export-page-content / export.go
index 8825bf6369f039e0e76a58dc25d5271c53d0a899..72d9d1f5991ba7549935f5784a0063eeefa2fca8 100644 (file)
@@ -48,7 +48,7 @@ func main() {
                book := bookIdMap[fullPage.BookId]
                path := book.Slug
                if chapter, ok := chapterIdMap[fullPage.ChapterId]; ok {
-                       path = "/" + chapter.Slug
+                       path += "/" + chapter.Slug
                }
 
                // Get the html, or markdown, content from our page along with the file name
@@ -74,14 +74,18 @@ func main() {
 
                // Write the content to the filesystem
                fPath := filepath.Join(absPath, fName)
-               err = os.WriteFile(fPath, []byte(content), 0644)
-               if err != nil {
-                       panic(err)
-               }
+               go writeOutPageContent(fPath, content)
 
                // Wait to avoid hitting rate limits
-               time.Sleep(time.Second / 4)
+               time.Sleep(time.Second / 6)
                currentCount++
        }
 
 }
+
+func writeOutPageContent(path string, content string) {
+       err := os.WriteFile(path, []byte(content), 0644)
+       if err != nil {
+               panic(err)
+       }
+}