]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
WIP
authorDavid Stainton <dstainton415@gmail.com>
Fri, 12 Jun 2015 08:42:02 +0000 (01:42 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:43 +0000 (01:19 +0100)
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index 29fd238ef0b7f8a54ba3607f72db6a4462ed97d0..94b3a293899b128e951e5f68f356f1788c7d8044 100644 (file)
@@ -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)
index e6edd93d31c11258221b0096117cd5a752615e52..9ee372dc2134d8785bc1d7ead9ee2a8b9ed5ac50 100644 (file)
@@ -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")