Fix databag item update for recent versions of chef (>10) and add commis/wsgi.py
Here's a fix for the databag item update bug discussed in Issue #13 (https://github.com/coderanger/commis/issues/13).
I also added wsgi.py... it can't hurt ! ;-)
ps: I pushed 2 untested and buggy commits before getting the thing to work in the 3rd commit. I know I could hack around the git history to remove these, but I don't have much time, so I hope you won't mind.
You're right, there's really no reason at all to have an indent here.
I added fixes for issues 15 & 16 regarding file upload.
And yet you haven't fixed the indent so I can't merge it ;-)
I'm also not sure your upload logic is correct. The point is that if the checksum already exists on the server it shouldn't be uploaded again, there should just be a new metadata entry in the cookbook version pointing at the same file data.
Hi, I just removed the indent. :-) I think my upload logic does what you're describing: first I try to find the CookbookFile for the given type and path (btw, wouldn't the path be sufficient?): cookbook_file = cookbook.files.get(type=type, path=file_info["path"]) if it does not exist, then create it. If the cookbook_file's content (aka SandboxFile) matches the requested checksum, then we're done. But if it does not (*), then we search for an already uploaded content matching the requested checksum. If it exists, then we point the cookbook_file to it. If it does not exists, we raise an Exception, so that the file will be uploaded.
Does this sound ok to you?
Cheers, Aurélien
(*) This can happen if someone modifies a cookbook and forgets to change its version (or does not want to, for some reason) and then uploads the cookbook. Before my patch, I ended up with two cookbook_files for the same path (one for the old content, one for the new content).