Fix server rebuild when adding a new leaf bundle with resources in on… · gohugoio/hugo@13b43e6 (original) (raw)

`@@ -830,6 +830,7 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo

`

830

830

``

831

831

`changedPaths := struct {

`

832

832

`changedFiles []*paths.Path

`

``

833

`+

addedFiles []*paths.Path

`

833

834

`changedDirs []*paths.Path

`

834

835

`deleted []*paths.Path

`

835

836

` }{}

`

`@@ -896,13 +897,15 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo

`

896

897

`changedPaths.deleted = append(changedPaths.deleted, pss...)

`

897

898

` } else if ev.isChangedDir {

`

898

899

`changedPaths.changedDirs = append(changedPaths.changedDirs, pss...)

`

``

900

`+

} else if ev.added {

`

``

901

`+

changedPaths.addedFiles = append(changedPaths.addedFiles, pss...)

`

899

902

` } else {

`

900

903

`changedPaths.changedFiles = append(changedPaths.changedFiles, pss...)

`

901

904

` }

`

902

905

` }

`

903

906

``

904

907

`// Find the most specific identity possible.

`

905

``

`-

handleChange := func(pathInfo *paths.Path, delete, isDir bool) {

`

``

908

`+

handleChange := func(pathInfo *paths.Path, delete, add, isDir bool) {

`

906

909

`switch pathInfo.Component() {

`

907

910

`case files.ComponentFolderContent:

`

908

911

`logger.Println("Source changed", pathInfo.Path())

`

`@@ -963,7 +966,10 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo

`

963

966

` }

`

964

967

` }

`

965

968

``

966

``

`-

addedOrChangedContent = append(addedOrChangedContent, pathChange{p: pathInfo, structural: delete, isDir: isDir})

`

``

969

`+

structural := delete

`

``

970

`+

structural = structural || (add && pathInfo.IsLeafBundle())

`

``

971

+

``

972

`+

addedOrChangedContent = append(addedOrChangedContent, pathChange{p: pathInfo, structural: structural, isDir: isDir})

`

967

973

``

968

974

`case files.ComponentFolderLayouts:

`

969

975

`tmplChanged = true

`

`@@ -1019,6 +1025,7 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo

`

1019

1025

` }

`

1020

1026

``

1021

1027

`changedPaths.deleted = removeDuplicatePaths(changedPaths.deleted)

`

``

1028

`+

changedPaths.addedFiles = removeDuplicatePaths(changedPaths.addedFiles)

`

1022

1029

`changedPaths.changedFiles = removeDuplicatePaths(changedPaths.changedFiles)

`

1023

1030

``

1024

1031

`h.Log.Trace(logg.StringFunc(func() string {

`

`@@ -1029,6 +1036,11 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo

`

1029

1036

`sb.WriteString("path: " + p.Path())

`

1030

1037

`sb.WriteString("\n")

`

1031

1038

` }

`

``

1039

`+

sb.WriteString("Added:\n")

`

``

1040

`+

for _, p := range changedPaths.addedFiles {

`

``

1041

`+

sb.WriteString("path: " + p.Path())

`

``

1042

`+

sb.WriteString("\n")

`

``

1043

`+

}

`

1032

1044

`sb.WriteString("Changed:\n")

`

1033

1045

`for _, p := range changedPaths.changedFiles {

`

1034

1046

`sb.WriteString("path: " + p.Path())

`

`@@ -1074,15 +1086,19 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo

`

1074

1086

` }

`

1075

1087

``

1076

1088

`for _, deleted := range changedPaths.deleted {

`

1077

``

`-

handleChange(deleted, true, false)

`

``

1089

`+

handleChange(deleted, true, false, false)

`

``

1090

`+

}

`

``

1091

+

``

1092

`+

for _, id := range changedPaths.addedFiles {

`

``

1093

`+

handleChange(id, false, true, false)

`

1078

1094

` }

`

1079

1095

``

1080

1096

`for _, id := range changedPaths.changedFiles {

`

1081

``

`-

handleChange(id, false, false)

`

``

1097

`+

handleChange(id, false, false, false)

`

1082

1098

` }

`

1083

1099

``

1084

1100

`for _, id := range changedPaths.changedDirs {

`

1085

``

`-

handleChange(id, false, true)

`

``

1101

`+

handleChange(id, false, false, true)

`

1086

1102

` }

`

1087

1103

``

1088

1104

`for _, id := range changes {

`