alice bob test alice rewrite file
authorDavid Stainton <dstainton415@gmail.com>
Tue, 14 Jul 2015 21:54:09 +0000 (14:54 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 20 Jul 2015 23:48:10 +0000 (00:48 +0100)
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index 6169161b6902bf304fe189fdd12785ecde0de50b..fc9a2ad107027e08d0799001ee41f2f87e483652 100644 (file)
@@ -407,7 +407,7 @@ class MagicFolder(service.MultiService):
                     d2.addCallback(get_metadata)
                     def set_deleted(metadata):
                         current_version = self._db.get_local_file_version(path) + 1
-                        metadata['version'] = current_version
+                        metadata['version'] = current_version + 1
                         metadata['deleted'] = True
                         emptyUploadable = Data("", self._convergence)
                         return self._upload_dirnode.add_file(name, emptyUploadable, overwrite=True, metadata=metadata)
@@ -424,6 +424,7 @@ class MagicFolder(service.MultiService):
                     version = 1
                 else:
                     version += 1
+                print "NEW VERSION ", version
                 d2 = _add_file(name, version)
                 def add_db_entry(filenode):
                     filecap = filenode.get_uri()
index 0a8ac9fc03ac1e3fed2590a7020f72c0646cb6d8..279cffc3de2e5a9043ef101cb5be45f6b21d7fdc 100644 (file)
@@ -360,10 +360,25 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(Alice_delete_file)
         d.addCallback(Alice_wait_for_upload)
         d.addCallback(Alice_prepare_for_alice_stats)
-        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 2)) # XXX ?
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 2))
         d.addCallback(Bob_wait_for_download)
         d.addCallback(Bob_prepare_for_stats)
-        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_downloaded'), 2)) # XXX ?
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_downloaded'), 2))
+
+        def Alice_rewrite_file(result):
+            print "Alice rewrites file\n"
+            self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder._local_dir)
+            fileutil.write(self.file_path, "Alice suddenly sees the white rabbit running into the forest.")
+            self.magicfolder = self.alice_magicfolder
+            self.notify(to_filepath(self.file_path), self.inotify.IN_CLOSE_WRITE)
+        d.addCallback(Alice_rewrite_file)
+
+        d.addCallback(Alice_wait_for_upload)
+        d.addCallback(Alice_prepare_for_alice_stats)
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 3))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.files_uploaded'), 2))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 0))
 
         def cleanup_Alice_and_Bob(result):
             d = defer.succeed(None)