]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Teach uploader to use flat hierarchy. refs ticket:2442
authorDaira Hopwood <daira@jacaranda.org>
Sun, 7 Jun 2015 13:26:30 +0000 (14:26 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Sun, 7 Jun 2015 13:28:22 +0000 (14:28 +0100)
Author: David Stainton <david@leastauthority.com>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py

index 7e2981f83201c94f67f689f75ab5be0448e0f51e..4e1e970f66424b96c2494ebe76d35cfc383272bc 100644 (file)
@@ -1,5 +1,6 @@
 
 import sys, os, stat
+import os.path
 from collections import deque
 
 from twisted.internet import defer, reactor, task
@@ -11,9 +12,8 @@ from allmydata.interfaces import IDirectoryNode, NoSuchChildError, ExistingChild
 from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath
 from allmydata.util.encodingutil import listdir_unicode, to_filepath, \
      unicode_from_filepath, quote_local_unicode_path, FilenameEncodingError
-from allmydata.immutable.upload import FileName
-
-from allmydata import backupdb
+from allmydata.immutable.upload import FileName, Data
+from allmydata import backupdb, magicpath
 
 
 class DropUploader(service.MultiService):
@@ -183,7 +183,9 @@ class DropUploader(service.MultiService):
 
         def _add_dir(ignore, name):
             self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], recursive=True)
-            d2 = self._parent.create_subdirectory(name, overwrite=False)
+            u = Data("", self._convergence)
+            name += "@_"
+            d2 = self._parent.add_file(name, u)
             def _err(f):
                 f.trap(ExistingChildError)
                 self._log("subdirectory %r already exists" % (path,))
@@ -197,7 +199,10 @@ class DropUploader(service.MultiService):
 
         def _maybe_upload(val):
             self._pending.remove(path)
-            name = os.path.basename(path)
+            relpath = os.path.relpath(path, self._local_dir)
+            name = magicpath.path2magic(relpath)
+            # XXX
+            #name = os.path.basename(path)
 
             if not os.path.exists(path):
                 self._log("uploader: not uploading non-existent file.")