spanezz / staticsite

Static site generator
GNU General Public License v3.0
46 stars 7 forks source link

file modification treated as UTC resulting in assets from the future #6

Closed DonKult closed 7 years ago

DonKult commented 7 years ago

Hi,

I was puzzled for a while testing staticsite as as soon as I was modifying an asset like a CSS file it would disappear from the build and no amount of revert fixed that…

Turns out that with some debugging after touching an asset file staticsite believes that asset is from the future and not including it as a draft… That is caused by code in staticsite/asset.py which assumes that the modification time of a file is UTC and should be localized, while it is 'badly' localized already, just without a timezone… I worked around it locally with dt = datetime.datetime.fromtimestamp(os.path.getmtime(self.src_abspath), pytz.timezone(settings.TIMEZONE)) which works, but depending on the timezone setting is likely not what staticsite should do here.

spanezz commented 7 years ago

Now, that explains why a couple of days ago I could not make staticsite see an image I just added to it, then I went to have dinner and the problem had magically solved itself. I had called on the others that were at home with me at the time to be witnesses to the backscroll of my terminal and tell me they could see it, too, and I had started freaking about about having to debug potential bugs based on nondeterministic ordering of dict iterations or something like that. I hadn't thought about timezones, and this seems easier to tackle :)