commis icon indicating copy to clipboard operation
commis copied to clipboard

Fix databag item update for recent versions of chef (>10) and add commis/wsgi.py

Open ageron opened this issue 12 years ago • 5 comments

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.

ageron avatar Apr 18 '13 19:04 ageron

You're right, there's really no reason at all to have an indent here.

ageron avatar Apr 18 '13 20:04 ageron

I added fixes for issues 15 & 16 regarding file upload.

ageron avatar Apr 19 '13 08:04 ageron

And yet you haven't fixed the indent so I can't merge it ;-)

coderanger avatar Apr 20 '13 20:04 coderanger

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.

coderanger avatar Apr 20 '13 20:04 coderanger

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).

ageron avatar Apr 20 '13 21:04 ageron