]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Use absolute paths in tahoe cp and tahoe backup. refs #2235
authorDaira Hopwood <daira@jacaranda.org>
Mon, 25 Aug 2014 18:09:40 +0000 (19:09 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 30 Jan 2015 00:47:35 +0000 (00:47 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/scripts/cli.py
src/allmydata/scripts/tahoe_backup.py
src/allmydata/scripts/tahoe_cp.py

index 4fb9b66c3bf9f5f10fc83daf8abc2fbf50fd85cb..e0e505df4b4cd660785c2bbaf462a4e37d332cb8 100644 (file)
@@ -347,7 +347,7 @@ class BackupOptions(FilesystemOptions):
         self['exclude'] = set()
 
     def parseArgs(self, localdir, topath):
-        self.from_dir = argv_to_unicode(localdir)
+        self.from_dir = argv_to_abspath(localdir)
         self.to_dir = argv_to_unicode(topath)
 
     def getSynopsis(self):
index e52407a6f5eb3e98a682e152f782d56b79f904f3..f12b3171303f996ac1ef663ae75b5b6806410282 100644 (file)
@@ -12,7 +12,7 @@ from allmydata.scripts import backupdb
 from allmydata.util.encodingutil import listdir_unicode, quote_output, \
      quote_local_unicode_path, to_str, FilenameEncodingError, unicode_to_url
 from allmydata.util.assertutil import precondition
-from allmydata.util.fileutil import abspath_expanduser_unicode
+from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath
 
 
 def get_local_metadata(path):
@@ -160,7 +160,7 @@ class BackerUpper:
         print >>self.options.stderr, msg
 
     def process(self, localpath):
-        precondition(isinstance(localpath, unicode), localpath)
+        precondition_abspath(localpath)
         # returns newdircap
 
         quoted_path = quote_local_unicode_path(localpath)
@@ -289,7 +289,7 @@ class BackerUpper:
 
     # This function will raise an IOError exception when called on an unreadable file
     def upload(self, childpath):
-        precondition(isinstance(childpath, unicode), childpath)
+        precondition_abspath(childpath)
 
         #self.verboseprint("uploading %s.." % quote_local_unicode_path(childpath))
         metadata = get_local_metadata(childpath)
index dc62145d89cebcda329db8478397ecbe9722b615..3bb9550aeb4c36e87152f563c0e118c420a5063d 100644 (file)
@@ -9,7 +9,7 @@ from allmydata.scripts.common import get_alias, escape_path, \
 from allmydata.scripts.common_http import do_http, HTTPError
 from allmydata import uri
 from allmydata.util import fileutil
-from allmydata.util.fileutil import abspath_expanduser_unicode
+from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath
 from allmydata.util.encodingutil import unicode_to_url, listdir_unicode, quote_output, \
     quote_local_unicode_path, to_str
 from allmydata.util.assertutil import precondition
@@ -62,37 +62,34 @@ def make_tahoe_subdirectory(nodeurl, parent_writecap, name):
 
 class LocalFileSource:
     def __init__(self, pathname):
-        precondition(isinstance(pathname, unicode), pathname)
+        precondition_abspath(pathname)
         self.pathname = pathname
 
     def need_to_copy_bytes(self):
         return True
 
     def open(self, caps_only):
-        return open(os.path.expanduser(self.pathname), "rb")
-
+        return open(self.pathname, "rb")
 
 class LocalFileTarget:
     def __init__(self, pathname):
-        precondition(isinstance(pathname, unicode), pathname)
+        precondition_abspath(pathname)
         self.pathname = pathname
 
     def put_file(self, inf):
         fileutil.put_file(self.pathname, inf)
 
-
 class LocalMissingTarget:
     def __init__(self, pathname):
-        precondition(isinstance(pathname, unicode), pathname)
+        precondition_abspath(pathname)
         self.pathname = pathname
 
     def put_file(self, inf):
         fileutil.put_file(self.pathname, inf)
 
-
 class LocalDirectorySource:
     def __init__(self, progressfunc, pathname):
-        precondition(isinstance(pathname, unicode), pathname)
+        precondition_abspath(pathname)
 
         self.progressfunc = progressfunc
         self.pathname = pathname
@@ -120,7 +117,7 @@ class LocalDirectorySource:
 
 class LocalDirectoryTarget:
     def __init__(self, progressfunc, pathname):
-        precondition(isinstance(pathname, unicode), pathname)
+        precondition_abspath(pathname)
 
         self.progressfunc = progressfunc
         self.pathname = pathname
@@ -161,6 +158,7 @@ class LocalDirectoryTarget:
     def set_children(self):
         pass
 
+
 class TahoeFileSource:
     def __init__(self, nodeurl, mutable, writecap, readcap):
         self.nodeurl = nodeurl
@@ -519,6 +517,8 @@ class Copier:
     def to_stderr(self, text):
         print >>self.stderr, text
 
+    # FIXME reduce the amount of near-duplicate code between get_target_info and get_source_info.
+
     def get_target_info(self, destination_spec):
         rootcap, path = get_alias(self.aliases, destination_spec, None)
         if rootcap == DefaultAliasMarker: