From: Daira Hopwood Date: Sun, 7 Jun 2015 13:26:30 +0000 (+0100) Subject: Teach uploader to use flat hierarchy. refs ticket:2442 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/%22file:/vdrive?a=commitdiff_plain;h=fb0253b710ef7717522df45a15d820559b18c76f;p=tahoe-lafs%2Ftahoe-lafs.git Teach uploader to use flat hierarchy. refs ticket:2442 Author: David Stainton Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index 7e2981f8..4e1e970f 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -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.")