]> khamidou — GitHub mirrors - cagibi.git/commitdiff
WIP fixing bugs
authorkarim hamidou <khamidou@gmail.com>
Wed, 18 Jul 2012 07:59:41 +0000 (09:59 +0200)
committerkarim hamidou <khamidou@gmail.com>
Wed, 18 Jul 2012 07:59:41 +0000 (09:59 +0200)
cagibi/cagibi.py
cagibi/server.py

index 0f1607e31684f7f6e06fac706c63f16dedf5535e..34e3d53326e82a64bfd99648047dd9456e61d229 100644 (file)
@@ -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
index 2a5f5a246646f74b23bb29c639412e64c40b1709..a90081a8471e65dd2890b99f74e97489596389da 100644 (file)
@@ -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/<filename>/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)