mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 02:43:09 +00:00
Separate reading source and processing source operations
This commit is contained in:
parent
f3aa93fa48
commit
bcc42c0549
1 changed files with 20 additions and 14 deletions
|
@ -509,6 +509,7 @@ func readData(f *source.File) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) Process() (err error) {
|
func (s *Site) Process() (err error) {
|
||||||
|
s.timerStep("Go initialization")
|
||||||
if err = s.initialize(); err != nil {
|
if err = s.initialize(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -535,7 +536,6 @@ func (s *Site) Process() (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.setupPrevNext()
|
s.setupPrevNext()
|
||||||
s.timerStep("import pages")
|
|
||||||
if err = s.BuildSiteMeta(); err != nil {
|
if err = s.BuildSiteMeta(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -688,21 +688,19 @@ type pageResult struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) CreatePages() error {
|
func (s *Site) ReadPagesFromSource() chan error {
|
||||||
if s.Source == nil {
|
if s.Source == nil {
|
||||||
panic(fmt.Sprintf("s.Source not set %s", s.absContentDir()))
|
panic(fmt.Sprintf("s.Source not set %s", s.absContentDir()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(s.Source.Files()) < 1 {
|
if len(s.Source.Files()) < 1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
files := s.Source.Files()
|
files := s.Source.Files()
|
||||||
|
|
||||||
results := make(chan HandledResult)
|
results := make(chan HandledResult)
|
||||||
filechan := make(chan *source.File)
|
filechan := make(chan *source.File)
|
||||||
|
|
||||||
procs := getGoMaxProcs()
|
procs := getGoMaxProcs()
|
||||||
|
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
|
|
||||||
wg.Add(procs * 4)
|
wg.Add(procs * 4)
|
||||||
|
@ -721,18 +719,19 @@ func (s *Site) CreatePages() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(filechan)
|
close(filechan)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
close(results)
|
close(results)
|
||||||
|
|
||||||
readErrs := <-errs
|
return errs
|
||||||
|
}
|
||||||
|
|
||||||
results = make(chan HandledResult)
|
func (s *Site) ConvertSource() chan error {
|
||||||
|
errs := make(chan error)
|
||||||
|
results := make(chan HandledResult)
|
||||||
pageChan := make(chan *Page)
|
pageChan := make(chan *Page)
|
||||||
fileConvChan := make(chan *source.File)
|
fileConvChan := make(chan *source.File)
|
||||||
|
procs := getGoMaxProcs()
|
||||||
wg = &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
|
|
||||||
wg.Add(2 * procs * 4)
|
wg.Add(2 * procs * 4)
|
||||||
for i := 0; i < procs*4; i++ {
|
for i := 0; i < procs*4; i++ {
|
||||||
|
@ -752,12 +751,18 @@ func (s *Site) CreatePages() error {
|
||||||
|
|
||||||
close(pageChan)
|
close(pageChan)
|
||||||
close(fileConvChan)
|
close(fileConvChan)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
close(results)
|
close(results)
|
||||||
|
|
||||||
renderErrs := <-errs
|
return errs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Site) CreatePages() error {
|
||||||
|
readErrs := <-s.ReadPagesFromSource()
|
||||||
|
s.timerStep("read pages from source")
|
||||||
|
|
||||||
|
renderErrs := <-s.ConvertSource()
|
||||||
|
s.timerStep("convert source")
|
||||||
|
|
||||||
if renderErrs == nil && readErrs == nil {
|
if renderErrs == nil && readErrs == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -768,6 +773,7 @@ func (s *Site) CreatePages() error {
|
||||||
if readErrs == nil {
|
if readErrs == nil {
|
||||||
return renderErrs
|
return renderErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("%s\n%s", readErrs, renderErrs)
|
return fmt.Errorf("%s\n%s", readErrs, renderErrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue