@@ -36,6 +36,7 @@ import (
3636 "github.com/dustin/go-humanize"
3737 "github.com/gobwas/glob"
3838 "github.com/gohugoio/hugo/common/loggers"
39+ "github.com/gohugoio/hugo/common/para"
3940 "github.com/gohugoio/hugo/config"
4041 "github.com/gohugoio/hugo/deploy/deployconfig"
4142 "github.com/gohugoio/hugo/media"
@@ -487,7 +488,12 @@ func knownHiddenDirectory(name string) bool {
487488// walkLocal walks the source directory and returns a flat list of files,
488489// using localFile.SlashPath as the map keys.
489490func (d * Deployer ) walkLocal (fs afero.Fs , matchers []* deployconfig.Matcher , include , exclude glob.Glob , mediaTypes media.Types , mappath func (string ) string ) (map [string ]* localFile , error ) {
490- retval := map [string ]* localFile {}
491+ retval := make (map [string ]* localFile )
492+ var mu sync.Mutex
493+
494+ workers := para .New (d .cfg .Workers )
495+ g , _ := workers .Start (context .Background ())
496+
491497 err := afero .Walk (fs , "" , func (path string , info os.FileInfo , err error ) error {
492498 if err != nil {
493499 return err
@@ -508,45 +514,54 @@ func (d *Deployer) walkLocal(fs afero.Fs, matchers []*deployconfig.Matcher, incl
508514 return nil
509515 }
510516
511- // When a file system is HFS+, its filepath is in NFD form.
512- if runtime .GOOS == "darwin" {
513- path = norm .NFC .String (path )
514- }
517+ // Process each file in a worker
518+ g .Run (func () error {
519+ // When a file system is HFS+, its filepath is in NFD form.
520+ if runtime .GOOS == "darwin" {
521+ path = norm .NFC .String (path )
522+ }
515523
516- // Check include/exclude matchers.
517- slashpath := filepath .ToSlash (path )
518- if include != nil && ! include .Match (slashpath ) {
519- d .logger .Infof (" dropping %q due to include\n " , slashpath )
520- return nil
521- }
522- if exclude != nil && exclude .Match (slashpath ) {
523- d .logger .Infof (" dropping %q due to exclude\n " , slashpath )
524- return nil
525- }
524+ // Check include/exclude matchers.
525+ slashpath := filepath .ToSlash (path )
526+ if include != nil && ! include .Match (slashpath ) {
527+ d .logger .Infof (" dropping %q due to include\n " , slashpath )
528+ return nil
529+ }
530+ if exclude != nil && exclude .Match (slashpath ) {
531+ d .logger .Infof (" dropping %q due to exclude\n " , slashpath )
532+ return nil
533+ }
526534
527- // Find the first matching matcher (if any).
528- var m * deployconfig.Matcher
529- for _ , cur := range matchers {
530- if cur .Matches (slashpath ) {
531- m = cur
532- break
535+ // Find the first matching matcher (if any).
536+ var m * deployconfig.Matcher
537+ for _ , cur := range matchers {
538+ if cur .Matches (slashpath ) {
539+ m = cur
540+ break
541+ }
533542 }
534- }
535- // Apply any additional modifications to the local path, to map it to
536- // the remote path.
537- if mappath != nil {
538- slashpath = mappath (slashpath )
539- }
540- lf , err := newLocalFile (fs , path , slashpath , m , mediaTypes )
541- if err != nil {
542- return err
543- }
544- retval [lf .SlashPath ] = lf
543+ // Apply any additional modifications to the local path, to map it to
544+ // the remote path.
545+ if mappath != nil {
546+ slashpath = mappath (slashpath )
547+ }
548+ lf , err := newLocalFile (fs , path , slashpath , m , mediaTypes )
549+ if err != nil {
550+ return err
551+ }
552+ mu .Lock ()
553+ retval [lf .SlashPath ] = lf
554+ mu .Unlock ()
555+ return nil
556+ })
545557 return nil
546558 })
547559 if err != nil {
548560 return nil , err
549561 }
562+ if err := g .Wait (); err != nil {
563+ return nil , err
564+ }
550565 return retval , nil
551566}
552567
0 commit comments