Avoid writing the same processed image to /public twice

Fixes #6307
This commit is contained in:
Bjørn Erik Pedersen 2019-09-06 09:28:43 +02:00
parent 901077c036
commit 9442937d82
3 changed files with 55 additions and 27 deletions

View file

@ -486,6 +486,8 @@ func (s *sitesBuilder) CreateSitesE() error {
return errors.Wrap(err, "failed to load config")
}
s.Fs.Destination = hugofs.NewCreateCountingFs(s.Fs.Destination)
depsCfg := s.depsCfg
depsCfg.Fs = s.Fs
depsCfg.Cfg = s.Cfg
@ -680,6 +682,12 @@ func (s *sitesBuilder) AssertImage(width, height int, filename string) {
s.Assert(cfg.Height, qt.Equals, height)
}
func (s *sitesBuilder) AssertNoDuplicateWrites() {
s.Helper()
d := s.Fs.Destination.(hugofs.DuplicatesReporter)
s.Assert(d.ReportDuplicates(), qt.Equals, "")
}
func (s *sitesBuilder) FileContent(filename string) string {
s.T.Helper()
filename = filepath.FromSlash(filename)