Skip to content

Commit eed5a85

Browse files
committed
Copy the mtime on puppet generate types
When installing a new module it can maintain the file timestamps from the original tarball (like g10 does). puppet generate types uses the timestamp of when it ran. If you update a module to a release that was created before it ran puppet types generate, it will never update the types. This can happen with a module downgrade, or just when you regenerated types manually. By using --force the timestamps are ignored, but that's only a workaround. This new approach copies the mtime from the source file to the generated cache file. It is only considered up to date if the mtime matches.
1 parent 97f7854 commit eed5a85

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: lib/puppet/generate/type.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def format=(format)
4949
# @return [Boolean] Returns true if the output is up-to-date or false if not.
5050
def up_to_date?(outputdir)
5151
f = effective_output_path(outputdir)
52-
Puppet::FileSystem::exist?(f) && (Puppet::FileSystem::stat(@path) <=> Puppet::FileSystem::stat(f)) <= 0
52+
Puppet::FileSystem::exist?(f) && (Puppet::FileSystem::stat(@path) <=> Puppet::FileSystem::stat(f)) == 0
5353
end
5454

5555
# Gets the filename of the output file.
@@ -240,6 +240,7 @@ def self.generate(inputs, outputdir = nil, force = false)
240240
Puppet::FileSystem.open(effective_output_path, nil, 'w:UTF-8') do |file|
241241
file.write(result)
242242
end
243+
Puppet::FileSystem.touch(effective_output_path, Puppet::FileSystem::stat(input.path).mtime)
243244
rescue Exception => e
244245
@bad_input = true
245246
Puppet.log_exception(e, _("Failed to generate '%{effective_output_path}': %{message}") % { effective_output_path: effective_output_path, message: e.message })

0 commit comments

Comments
 (0)