]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
wip - confirming that the db persistence doesn't work
authorDavid Stainton <dstainton415@gmail.com>
Tue, 21 Apr 2015 17:48:14 +0000 (18:48 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:46:48 +0000 (19:46 +0100)
src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_drop_upload.py

index b915b9786f57ef326addbab84361ba422b816f22..c2691d1e3215df1abc4e66470741b6ecdf563a87 100644 (file)
@@ -123,9 +123,10 @@ class DropUploader(service.MultiService):
                 if must_upload:
                     self._append_to_deque(childpath)
             elif isfile:
-                print "isfile"
+                print "isfile %s" % (childpath,)
                 must_upload = self._check_db_file(childpath)
                 if must_upload:
+                    print "must_upload"
                     self._append_to_deque(childpath)
             else:
                 self.warn("WARNING: cannot backup special file %s" % quote_local_unicode_path(childpath))
@@ -210,8 +211,8 @@ class DropUploader(service.MultiService):
             if sys.platform != "win32":
                 name = name.decode(get_filesystem_encoding())
                 # XXX
-                #dirname = path.decode(get_filesystem_encoding())
-                dirname = path
+                dirname = path.decode(get_filesystem_encoding())
+                #dirname = path
 
             return self._parent.create_subdirectory(name)
 
@@ -230,6 +231,20 @@ class DropUploader(service.MultiService):
                 return None
             elif os.path.isfile(path):
                 d.addCallback(_add_file)
+                def add_db_entry(val):
+                    filecap = val.get_uri()
+                    print "filename %s filecap %s" % (path, filecap)
+                    s = os.stat(path)
+                    self._db.did_upload_file(filecap, path.decode('UTF-8'), s.st_mtime, s.st_ctime, s.st_size)
+
+                    #r = self._db.check_file(path.decode('UTF-8'))
+                    #was_uploaded = r.was_uploaded()
+                    #if was_uploaded:
+                    #    print "was_uploaded true"
+                    #else:
+                    #    print "was_uploaded false"
+
+                d.addCallback(add_db_entry)
                 self._stats_provider.count('drop_upload.files_uploaded', 1)
                 return None
             else:
index 08476f9936293b23c142d3f9fbf5ae9341c59c44..98f56837bc7fcad510ca23bae822e73f093ab7a4 100644 (file)
@@ -158,12 +158,13 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
         d.addCallback(self._cleanup)
         d.addCallback(lambda ign: self.client.removeService(self.uploader))
-
+        def msg(val):
+            print "stopped and removed uploader service."
+        d.addCallback(msg)
         d.addCallback(self._made_upload_dir)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1))
         d.addBoth(self._cleanup)
-
         return d
 
     def _test(self):