@@ -830,6 +830,7 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
830830
831831 changedPaths := struct {
832832 changedFiles []* paths.Path
833+ addedFiles []* paths.Path
833834 changedDirs []* paths.Path
834835 deleted []* paths.Path
835836 }{}
@@ -896,13 +897,15 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
896897 changedPaths .deleted = append (changedPaths .deleted , pss ... )
897898 } else if ev .isChangedDir {
898899 changedPaths .changedDirs = append (changedPaths .changedDirs , pss ... )
900+ } else if ev .added {
901+ changedPaths .addedFiles = append (changedPaths .addedFiles , pss ... )
899902 } else {
900903 changedPaths .changedFiles = append (changedPaths .changedFiles , pss ... )
901904 }
902905 }
903906
904907 // 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 ) {
906909 switch pathInfo .Component () {
907910 case files .ComponentFolderContent :
908911 logger .Println ("Source changed" , pathInfo .Path ())
@@ -963,7 +966,10 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
963966 }
964967 }
965968
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 })
967973
968974 case files .ComponentFolderLayouts :
969975 tmplChanged = true
@@ -1019,6 +1025,7 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
10191025 }
10201026
10211027 changedPaths .deleted = removeDuplicatePaths (changedPaths .deleted )
1028+ changedPaths .addedFiles = removeDuplicatePaths (changedPaths .addedFiles )
10221029 changedPaths .changedFiles = removeDuplicatePaths (changedPaths .changedFiles )
10231030
10241031 h .Log .Trace (logg .StringFunc (func () string {
@@ -1029,6 +1036,11 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
10291036 sb .WriteString ("path: " + p .Path ())
10301037 sb .WriteString ("\n " )
10311038 }
1039+ sb .WriteString ("Added:\n " )
1040+ for _ , p := range changedPaths .addedFiles {
1041+ sb .WriteString ("path: " + p .Path ())
1042+ sb .WriteString ("\n " )
1043+ }
10321044 sb .WriteString ("Changed:\n " )
10331045 for _ , p := range changedPaths .changedFiles {
10341046 sb .WriteString ("path: " + p .Path ())
@@ -1074,15 +1086,19 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
10741086 }
10751087
10761088 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 )
10781094 }
10791095
10801096 for _ , id := range changedPaths .changedFiles {
1081- handleChange (id , false , false )
1097+ handleChange (id , false , false , false )
10821098 }
10831099
10841100 for _ , id := range changedPaths .changedDirs {
1085- handleChange (id , false , true )
1101+ handleChange (id , false , false , true )
10861102 }
10871103
10881104 for _ , id := range changes {
0 commit comments