Commit 73bf1f64 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Make download overwrite more intuitive

parent fac340da
......@@ -516,7 +516,7 @@ class pithos(object):
try:
return func(self, *args, **kwargs)
except IOError as ioe:
msg = 'Failed to access a file',
msg = 'Failed to access a local file',
raiseCLIError(ioe, msg, importance=2, details=[
'Check if the file exists. Also check if the remote',
'directories exist. All directories in a remote path',
......
......@@ -1206,11 +1206,29 @@ class file_download(_pithos_container):
parsed_name, self.container)])
else:
# Remote object is just a file
if path.exists(local_path) and not self['resume']:
raise CLIError(
'Cannot overwrite local file %s' % (local_path),
details=['To overwrite/resume, use %s' % (
self.arguments['resume'].lvalue)])
if path.exists(local_path):
if not self['resume']:
raise CLIError(
'Cannot overwrite local file %s' % (local_path),
details=['To overwrite/resume, use %s' % (
self.arguments['resume'].lvalue)])
elif '/' in local_path[1:-1]:
dirs = [p for p in local_path.split('/') if p]
pref = '/' if local_path.startswith('/') else ''
for d in dirs[:-1]:
pref += d
if not path.exists(pref):
ret.append((None, d, None))
elif not path.isdir(pref):
raise CLIError(
'Failed to use %s as a destination' % local_path,
importance=3,
details=[
'Local file %s is not a directory' % pref,
'Destination prefix must consist of '
'directories or non-existing names',
'Either remove the file, or choose another '
'destination'])
ret.append((rpath, local_path, self['resume']))
for r, l, resume in ret:
if r:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment