-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to not modify mtime on unmodified files #10842
Comments
Why not use |
There are plenty of workarounds.
For fingerprinted files all that is needed is a check for existence before writing. For static files, I believe the behaviour is already not to update the mtime on copy. For non fingerprinted, there is obviously a performance hit because the read has to come from disk whereas the write would be cached, and there is a byte by byte comparison with the string in memory to do. I suspect that this overhead is tiny, particularly in go, but putting it behind a flag would mitigate this anyway. |
See aws/aws-cli#6750. That's the right place to address your use case. |
I don't think that aws-cli is being particularly unreasonable in assuming that a file with a newer mtime has been updated. Sure, aws-cli could, and probably will in the future, incorporate a checksum comparison to account for unmodified files with changed mtimes, but that is still basically a workaround and is specific to aws. Something, somewhere has to decide that the file is unchanged and therefore doesn't need synchronising. That can be the synchronising tool itself; it can be, as I am doing, a script run between the hugo run and the synchronising tool; or it can be hugo. Of the options, the most natural and efficient is to do it in hugo -- hugo knows what's static, knows what's fingerprinted and has the string ready in memory for everything else. As I say, it's not something that is personally causing me trouble; I'm quite happy with my solution. I do, however, believe it would be a useful feature if hugo could, behind a flag if necessary, only change mtimes when files have been modified. |
filezilla is another file sychronisation tool which can use modification time and size to decide whether or not to upload a file. i for one would welcome this flag/feature as it would save many useless uploads. not everyone is using cloud/webhosting scripts or git for development and uploads of websites. |
Not quite the same thing, but I'd like a way to set mtime of each generated file to be the same as whatever Setting mtime based on For now I think I'm going to have to write the times into a Dublin Core last modification meta element in the head, then write a utility to walk the |
@lpar This makes sense, but remember that some pages may not be backed by a file (e.g., top level sections, taxonomy pages, term pages). Those would have |
This seems a bit easier:
Files of interest:
Create a data file while building the site, then run a short script. On my rather average laptop, it takes about 2 seconds to run against a 500 page site, and about 8 seconds for a 2000 page site. |
Oh, that's cunning. The shell script doesn't work when I test because I'm on a Mac so bash is years out of date and there's no
[mediaTypes]
[mediaTypes."text/x-shellscript"]
suffixes = ["sh"]
[outputFormats.lastmod]
baseName = 'lastmod'
isPlainText = true
mediaType = 'text/x-shellscript'
notAlternative = true
[outputs]
home = ["HTML","JSON","lastmod"]
Then I can just run Normally this would be a terrible idea for security reasons, but since there's no user content being placed directly in the shell script and it's running in a container anyway, I think it's OK for this particular task. |
Works fine here as well (had to change Minute though, as it refers to '03' and should be '04') |
@mboelen Thanks, the bug was fixed in our internal copy a few days later but I forgot to come back here and update. I've updated the original comment now in case anyone copypastes it without reading the rest of the thread. |
Naïve sychronisers such as aws s3 sync rely on file size and file modification time to decide whether to upload a file. Hugo appears to overwrite existing files, updating their file modification time, even when the file in question is unchanged.
I propose that something like a --preserveModificationTimes flag be added. This would cause Hugo to check whether a file that it is about to overwrite has identical content and cancel the operation if this is the case, thus preserving the mtime.
The text was updated successfully, but these errors were encountered: