]> 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)
committerDavid Stainton <dstainton415@gmail.com>
Tue, 21 Apr 2015 17:48:14 +0000 (18:48 +0100)
src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_drop_upload.py

index d6e9e60876bcc61b5cd69c74b6f969d2838a57f0..1d3387589b06d8ce6f4cbf1c18fbae0f9e4f524e 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))
@@ -205,8 +206,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)
 
@@ -225,6 +226,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 f16888821c63b01ed2bf5afc1632a89433e55027..825f515c0d28fa415f5915fc4f4954a5e9dc5af2 100644 (file)
@@ -157,12 +157,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):