mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +00:00
Use absolute paths in tahoe cp and tahoe backup. refs #2235
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
21b477f235
commit
4a0cdce86b
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user