From: David Stainton Date: Fri, 12 Jun 2015 08:42:02 +0000 (-0700) Subject: WIP X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/%22doc.html/README.win32?a=commitdiff_plain;h=68fac1ca2417cc4054c0132f75e0217a85d8c2d2;p=tahoe-lafs%2Ftahoe-lafs.git WIP --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 29fd238e..94b3a293 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -192,6 +192,7 @@ class MagicFolder(service.MultiService): return self._upload_dirnode.add_file(name, u, overwrite=True) def _add_dir(name): + print "MEOWMEOW!" self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], recursive=True) u = Data("", self._convergence) name += "@_" @@ -216,22 +217,21 @@ class MagicFolder(service.MultiService): "(this is normal for temporary objects)" % (path,)) self._stats_provider.count('magic_folder.objects_disappeared', 1) - # XXX todo: check if file exists in magic folder db - # ... + d2 = defer.Succeed(None) if not self._db.check_file_db_exists(path): - return None + pass else: - u = Data("", self._convergence) - d2 = defer.Succeed(None) def get_metadata(d): - return self._parent.get_metadata_for(name) + self._parent.get_metadata_for(name) d2.addCallback(get_metadata) def set_deleted(metadata): metadata['version'] += 1 metadata['deleted'] = True - return self._parent.add_file(name, u, overwrite=True, metadata=metadata) + emptyUploadable = Data("", self._convergence) + self._parent.add_file(name, emptyUploadable, overwrite=True, metadata=metadata) d2.addCallback(set_deleted) - return d2 + d2.addCallback(lambda x: Exception("file does not exist")) + return d2 elif os.path.islink(path): raise Exception("symlink not being processed") if os.path.isdir(path): @@ -294,4 +294,5 @@ class MagicFolder(service.MultiService): def _log(self, msg): self._client.log("drop-upload: " + msg) + print "_log %s" % (msg,) #open("events", "ab+").write(msg) diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index e6edd93d..9ee372dc 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -142,6 +142,7 @@ class MagicFolderTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, Non d.addCallback(self._create_magicfolder) def _check_move_empty_tree(res): + print "MEOW 0" self.mkdir_nonascii(empty_tree_dir) d2 = defer.Deferred() self.magicfolder.set_processed_callback(d2.callback, ignore_count=0) @@ -153,14 +154,16 @@ class MagicFolderTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, Non d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.files_uploaded'), 0)) 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'), 1)) - + def _check_move_small_tree(res): + print "MEOW 1" self.mkdir_nonascii(small_tree_dir) fileutil.write(abspath_expanduser_unicode(u"what", base=small_tree_dir), "say when") d2 = defer.Deferred() self.magicfolder.set_processed_callback(d2.callback, ignore_count=1) os.rename(small_tree_dir, new_small_tree_dir) self.notify(to_filepath(new_small_tree_dir), self.inotify.IN_MOVED_TO) + print "end of MEOW 1" return d2 d.addCallback(_check_move_small_tree) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 3)) @@ -169,6 +172,7 @@ class MagicFolderTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, Non d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 2)) def _check_moved_tree_is_watched(res): + print "MEOW 2" d2 = defer.Deferred() self.magicfolder.set_processed_callback(d2.callback, ignore_count=0) fileutil.write(abspath_expanduser_unicode(u"another", base=new_small_tree_dir), "file")