From: karim hamidou Date: Wed, 18 Jul 2012 07:59:41 +0000 (+0200) Subject: WIP fixing bugs X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0ccf1a20535f712378b94e8a626a369623c5753b;p=cagibi.git WIP fixing bugs --- diff --git a/cagibi/cagibi.py b/cagibi/cagibi.py index 0f1607e..34e3d53 100644 --- a/cagibi/cagibi.py +++ b/cagibi/cagibi.py @@ -22,7 +22,7 @@ def upload_local_changes(modified, added, removed): fd = urllib2.urlopen(url) hashes = json.load(fd) patchedfile = open(secure_path(cagibi_folder, file), "rb") - deltas = rsyncdelta(patchedfile, hashes) + deltas = list(rsyncdelta(patchedfile, hashes)) patchedfile.close() # Send the deltas to the server. @@ -85,7 +85,7 @@ def checkout_upstream_changes(): # Get it too, but using the rsync algo unpatched = open(secure_path(cagibi_folder, file).encode('ascii', 'ignore'), "rb") - hashes = blockchecksums(unpatched) + hashes = list(blockchecksums(unpatched)) json_hashes = json.dumps(hashes) post_data = {} post_data["hashes"] = json_hashes diff --git a/cagibi/server.py b/cagibi/server.py index 2a5f5a2..a90081a 100644 --- a/cagibi/server.py +++ b/cagibi/server.py @@ -72,19 +72,18 @@ def file_data(filename): def file_hashes(filename): """Return the hashes of a file""" unpatched = open(secure_path(cagibi_folder, filename), "rb") - hashes = blockchecksums(unpatched) - print hashes + hashes = list(blockchecksums(unpatched)) unpatched.close() return json.dumps(hashes) @post('/files//hashes') def update_file_hashes(filename): """Updates a file using the deltas received by a client""" - deltas = json.loads(request.forms.get("hashes")) + deltas = json.loads(request.forms.get("deltas")) unpatched = open(secure_path(cagibi_folder, filename), "rb") save_to = os.tmpfile() - patchstream(unpatched, save_to, json_response) + patchstream(unpatched, save_to, deltas) unpatched.close() os.unlink(secure_path(cagibi_folder, filename)) save_to.seek(0)