From 7e8577be067a180405d7b2b37547e685dfc62eb9 Mon Sep 17 00:00:00 2001
From: meejah <meejah@meejah.ca>
Date: Mon, 26 Oct 2015 11:25:56 -0600
Subject: [PATCH] add the 'spurious' notifies

---
 src/allmydata/frontends/magic_folder.py |  1 +
 src/allmydata/test/test_magic_folder.py | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index 4bfa16f1..61275372 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -625,6 +625,7 @@ class Downloader(QueueMixin, WriteFileMixin):
             if self._should_download(relpath_u, metadata['version']):
                 extension += [(relpath_u, file_node, metadata)]
             else:
+                self._log("Excluding '{0}'".format(relpath_u))
                 self._count('objects_excluded')
                 self._call_hook(None, 'processed')
         return extension
diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py
index a799f51a..88e5bc24 100644
--- a/src/allmydata/test/test_magic_folder.py
+++ b/src/allmydata/test/test_magic_folder.py
@@ -682,6 +682,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         def _wait_for_Bob(ign, downloaded_d):
             print "Now waiting for Bob to download\n"
+            self.magicfolder = self.bob_magicfolder
             bob_clock.advance(0)
             return downloaded_d
 
@@ -721,6 +722,19 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
             self.notify(to_filepath(self.file_path), self.inotify.IN_DELETE)
         d.addCallback(_wait_for, Alice_to_delete_file)
 
+        def notify_bob_moved(ign):
+            d0 = self.bob_magicfolder.uploader.set_hook('processed')
+            self.magicfolder = self.bob_magicfolder
+            p = abspath_expanduser_unicode(u"file1", base=self.bob_magicfolder.uploader._local_path_u)
+            self.notify(to_filepath(p), self.inotify.IN_MOVED_FROM)
+
+            def foo(x):
+                self.notify(to_filepath(p + u'.backup'), self.inotify.IN_MOVED_TO)
+                return ign
+            d0.addCallback(foo)
+            return d0
+        d.addCallback(notify_bob_moved)
+
         d.addCallback(lambda ign: self._check_version_in_dmd(self.alice_magicfolder, u"file1", 1))
         d.addCallback(lambda ign: self._check_version_in_local_db(self.alice_magicfolder, u"file1", 1))
         d.addCallback(_check_uploader_count, 'objects_failed', 0)
@@ -734,6 +748,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         def Alice_to_rewrite_file():
             print "Alice rewrites file\n"
+            self.magicfolder = self.alice_magicfolder
             self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder.uploader._local_path_u)
             fileutil.write(self.file_path, "Alice suddenly sees the white rabbit running into the forest.")
             self.notify(to_filepath(self.file_path), self.inotify.IN_CLOSE_WRITE)
@@ -771,7 +786,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         d.addCallback(lambda ign: self.failIf(os.path.exists(path_u)))
         d.addCallback(lambda ign: self._check_version_in_local_db(self.bob_magicfolder, encoded_path_u, None))
-        d.addCallback(_check_downloader_count, 'objects_excluded', 1)
+        d.addCallback(_check_downloader_count, 'objects_excluded', 2)
         d.addCallback(_check_downloader_count, 'objects_downloaded', 3)
 
         def _cleanup(ign, magicfolder, clock):
-- 
2.45.2