From: David Stainton Date: Tue, 14 Jul 2015 21:54:09 +0000 (-0700) Subject: alice bob test alice rewrite file X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/status?a=commitdiff_plain;h=6a3ac3f9693772364274e34d13d3909dc45a7924;p=tahoe-lafs%2Ftahoe-lafs.git alice bob test alice rewrite file --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 6169161b..fc9a2ad1 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -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() diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 0a8ac9fc..279cffc3 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -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)