electric-it / minimart

MiniMart RubyGem for Chef cookbook mirroring and storage.
Apache License 2.0
52 stars 20 forks source link

Always re-downloads cookbooks with path #19

Closed tapickell closed 8 years ago

tapickell commented 8 years ago

If you have a cookbook with a file path or git url it will always re-download even if it just got it and there are no changes to it. This seems inefficient and could be better, we can check to see if we already have cookbooks from the super market, why to we skip this check with ones that have a path or git url??

richardardrichard commented 8 years ago

When we get a cookbook from the Chef Supermarket we know that the cookbook is not going to change at that version. When we're dealing with a local file path we don't really know (without hashing the cookbook or something) if anyone has made any changes since we last got those files, and it's just easier to copy the files over. With Git it's basically the same thing, if you have minimart set up to track the master branch you would always expect minimart to get the latest changes any time it's run (adding some value of time in here to do this doesn't seem right). You would have to add something to get the remote SHA of the branch/tag you are tracking, and check it against the local version of the repo to ensure that it really hasn't changed (we blow away the .git directory of any cookbooks from git, you probably have to add this to the .minimart.json file we use to store some metadata about the cookbook). Check out https://github.com/electric-it/minimart/blob/master/lib/minimart/mirror/local_store.rb#L101-L103, and https://github.com/electric-it/minimart/blob/master/lib/minimart/mirror/inventory_builder.rb#L77

tapickell commented 8 years ago

Thank you @richardardrichard that makes more sense now why we do it that way. Seems legit.