]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
WIP
authorDavid Stainton <dstainton415@gmail.com>
Tue, 22 Dec 2015 16:09:44 +0000 (16:09 +0000)
committerDavid Stainton <dstainton415@gmail.com>
Tue, 26 Jan 2016 15:27:20 +0000 (15:27 +0000)
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index be468ea8874d12a73939a22ae2c29a2e3b147fd4..d25e9f743508f49a403488d728e51f7eedb45426 100644 (file)
@@ -21,7 +21,7 @@ from allmydata.util.encodingutil import listdir_filepath, to_filepath, \
 from allmydata.immutable.upload import FileName, Data
 from allmydata import magicfolderdb, magicpath
 
-
+defer.setDebugging(True)
 IN_EXCL_UNLINK = 0x04000000L
 
 def get_inotify_module():
@@ -168,6 +168,11 @@ class QueueMixin(HookMixin):
             self._log("deque is now empty")
             self._lazy_tail.addCallback(lambda ign: self._when_queue_is_empty())
         else:
+            print "_turn_deque else clause"
+            def whawhat(result):
+                print "result %r" % (result,)
+                return result
+            self._lazy_tail.addBoth(whawhat)
             self._lazy_tail.addCallback(lambda ign: self._process(item))
             self._lazy_tail.addBoth(self._call_hook, 'processed')
             self._lazy_tail.addErrback(log.err)
@@ -242,11 +247,10 @@ class Uploader(QueueMixin):
         for relpath_u in all_relpaths:
             self._add_pending(relpath_u)
 
-        self._periodic_full_scan(ignore_pending=True)
-        self._extend_queue_and_keep_going(self._pending)
+        self._full_scan()
 
     def _extend_queue_and_keep_going(self, relpaths_u):
-        self._log("queueing %r" % (relpaths_u,))
+        self._log("_extend_queue_and_keep_going %r" % (relpaths_u,))
         self._deque.extend(relpaths_u)
         self._count('objects_queued', len(relpaths_u))
 
@@ -256,20 +260,15 @@ class Uploader(QueueMixin):
             else:
                 self._clock.callLater(0, self._turn_deque)
 
-    def _periodic_full_scan(self, ignore_pending=False):
-        self.periodic_callid = self._clock.callLater(self._periodic_full_scan_duration, self._periodic_full_scan)
-        if ignore_pending:
-            self._full_scan()
-        else:
-            if len(self._pending) == 0:
-                self._full_scan()
-
     def _full_scan(self):
+        self.periodic_callid = self._clock.callLater(self._periodic_full_scan_duration, self._full_scan)
         print "FULL SCAN"
         self._log("_pending %r" % (self._pending))
         self._scan(u"")
+        self._extend_queue_and_keep_going(self._pending)
 
     def _add_pending(self, relpath_u):
+        self._log("add pending %r" % (relpath_u,))        
         if not magicpath.should_ignore_file(relpath_u):
             self._pending.add(relpath_u)
 
@@ -385,6 +384,7 @@ class Uploader(QueueMixin):
                 self.warn("WARNING: cannot upload symlink %s" % quote_filepath(fp))
                 return None
             elif pathinfo.isdir:
+                print "ISDIR "
                 if not getattr(self._notifier, 'recursive_includes_new_subdirectories', False):
                     self._notifier.watch(fp, mask=self.mask, callbacks=[self._notify], recursive=True)
 
index f5179769253f707eff277d07e16b0eea84407e4f..604d23a3c080acc88579db1a1e472e2bc63ea483 100644 (file)
@@ -1231,16 +1231,13 @@ class MockTest(MagicFolderTestMixin, unittest.TestCase):
 
         def _create_file_without_event(res):
             print "CREATE FILE WITHOUT EMITTING EVENT"
+            uploaded_d = self.magicfolder.uploader.set_hook('processed')
             what_path = abspath_expanduser_unicode(u"what", base=new_empty_tree_dir)
             fileutil.write(what_path, "say when")
-        d.addCallback(_create_file_without_event)
-        def advance_clock(res):
-            alice_clock.advance(20)
-        d.addCallback(advance_clock)
-        def hook(res):
-            uploaded_d = self.magicfolder.uploader.set_hook('processed')
+            print "ADVANCE CLOCK"
+            alice_clock.advance(self.magicfolder.uploader._periodic_full_scan_duration + 1)
             return uploaded_d
-        d.addCallback(hook)
+        d.addCallback(_create_file_without_event)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.files_uploaded'), 1))
         d.addCallback(lambda ign: self.magicfolder.finish())
         return d