]> khamidou — GitHub mirrors - cagibi.git/commitdiff
trying to find a complex bug
authorkarim hamidou <khamidou@gmail.com>
Sat, 28 Jul 2012 18:52:24 +0000 (20:52 +0200)
committerkarim hamidou <khamidou@gmail.com>
Sat, 28 Jul 2012 18:52:24 +0000 (20:52 +0200)
cagibi/cagibi.py
cagibi/watch.py

index 1c4652ad8ff44fbb051a5c7ddf1adcdb3bf7decd..d19c40cf4bbc2bf1b8140e85ee5d7c9fedcc36d2 100644 (file)
@@ -36,7 +36,6 @@ def setup_filewatcher_thread():
     fw = FileWatcher(path=cagibi_folder)
     fw.addHandler(push_filewatcher_changes)
     fw.watch()
-    print "ended"
 
 def push_filewatcher_changes(modified, added, removed):
     for file in added:
@@ -54,27 +53,30 @@ def upload_local_changes():
     while not mqueue["modified"].empty():
         file = mqueue["modified"].get()
         print "Detect %s modified" % file
-
+    
         url = "%s/files/%s/hashes" % (server_url, file)
         try:
             fd = urllib2.urlopen(url)
         except HTTPError:
             # The server may return us an error if things have gone south during
             # the file creation process.
+            # If so, mark the file as added instead of modified.
+            print "mark as added instead"
             mqueue["added"].put(file)
             continue
 
         hashes = json.load(fd)
         try:
+            print "%f" % os.path.getmtime(secure_path(cagibi_folder, file))
             patchedfile = open(secure_path(cagibi_folder, file), "rb")
             deltas = encode_deltas(rsyncdelta(patchedfile, hashes))
             patchedfile.close()
+            print "%f" % os.path.getmtime(secure_path(cagibi_folder, file))
         except IOError:
             "IOError - continuing"
             continue
 
         # Send the deltas to the server.
-        print "deltas: %s" % deltas
         post_data = {}
         post_data["deltas"] = json.dumps(deltas)
         post_string = urllib.urlencode(post_data)
@@ -84,6 +86,7 @@ def upload_local_changes():
         local_files = load_config("files.json")
         local_files[file]["rev"] = results["rev"]
         save_config("files.json")
+        print "%f" % os.path.getmtime(secure_path(cagibi_folder, file))
 
     opener = urllib2.build_opener(urllib2.HTTPHandler)
 
@@ -139,6 +142,7 @@ def checkout_upstream_changes():
         else:
             if server_files[file]["rev"] > local_files[file]["rev"]:
                 # Get it too, but using the rsync algo
+                print "Retrieving file, using the rsync algorithm"
 
                 try:
                     unpatched = open(secure_path(cagibi_folder, file), "rb")
@@ -168,6 +172,7 @@ def checkout_upstream_changes():
                     file_copy.write(save_to.read())
                     file_copy.close()
                     local_files[file]["rev"] = server_files[file]["rev"] 
+                    modified = True
                 except IOError:
                     continue
 
index f9a324378ba0770b2dd78a702cea23c8231a859e..a80dfdbbeffca7421e27d3f27666712e6121a5fb 100644 (file)
@@ -17,12 +17,12 @@ class FileWatcher:
         
         while not self.paused:
             elapsed_time = time.time()
-            time.sleep (10)
+            time.sleep(10)
             after = dict ([(f, None) for f in os.listdir (self.path)])
             added = [f for f in after if not f in before]
             removed = [f for f in before if not f in after]
             modified = [f for f in after if os.path.getmtime(os.path.join(self.path, f)) > elapsed_time and f not in added]
-            
+
             for handler in self.handlers:
                 handler(modified, added, removed)