Open UltCombo opened 9 years ago
Can we compute a hash or unique identifier for a build? As in building the site for the same files would result in the same hash being computed. This way we just compare the new build hash with the current build hash, if they are the same, no need to overwrite any RSS.
This hash can be computed concatenating all src/
files and calculating the md5 hash. Since this is a build step, it can be left for a gulp task.
What do you think?
@soapdog I guess that works, but isn't that overcomplicating things a bit? I was thinking about generating the RSS as usual (in memory), compare with the existing RSS (if any), and only overwrite if there are changes other than the publish date.
Only problem is that by the time we generate the RSS, the public
dir has already been completely wiped, including the old RSS. I guess this is a big issue for any approach that we may take.
So, another approach would be to read the existing RSS (if any) before wiping out the public
dir, so we can compare it with the new RSS and, if nothing changed besides the date, write the old RSS to disk. But this breaks down when there are multiple people deploying the site, as a second person may not have the public dir of the first person that deployed the site.
To solve this we would require to read a remote RSS (from the deployed site), but that's way too much effort and adds a requirement on supplying a deployment site URL config and add a dependency on having internet connection, plus slower build time due to the download. This is not good.
Unless we can think of something better, I guess it is better to leave this as is.
Actually, if we compute a hash (as you said) and save it to the harmonic.json
(e.g. _lastBuildHash
), then I guess we can make it work. :smile:
Also comparing the RSS to see if everything remain the same but the date in non-trivial if you're doing it right by comparing node contents and attributes. Since Harmonic doesn't maintain a database of built data, its hard for it to detect if it is building the same things over and over or new things.
@soapdog Right. But we do have the posts and pages' data -- we could JSON.stringify
and hash them.
@UltCombo I like this! Let me try to build a POC...
Currently, if a new build is generated without any changes, the RSS's publication date still changes. I believe this is not good.