Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an ignore-size option to force copy operations to execute even... #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions bin/boto-rsync
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ def main():
'size is 0. Warning: S3/GS often uses empty keys with special ' + \
'trailing characters to specify directories.'
)
parser.add_argument(
'--ignore-size', action='store_true',
help='Ignore file size comparisons. Copy the file even if the file ' + \
'is the same size'
)
parser.add_argument(
'--delete', action='store_true',
help='Delete extraneous files from destination dirs after the ' + \
Expand Down Expand Up @@ -325,6 +330,7 @@ def main():
no_recurse = args.no_recurse or glob
skip_dirkeys = args.skip_dirkeys
ignore_empty = args.ignore_empty
ignore_size = args.ignore_size
delete = args.delete
no_op = args.no_op
quiet = args.quiet
Expand Down Expand Up @@ -503,7 +509,7 @@ def main():
key_name.endswith('_$folder$'):
if not quiet:
sys.stdout.write(
'Skipping %s (size matches)\n' %
'Skipping %s (is directory)\n' %
key_name.replace('_$folder$', '/')
)
create_dirkey = False
Expand Down Expand Up @@ -559,7 +565,7 @@ def main():
fullpath[len(path):].lstrip(os.sep)
)
continue
elif keys[key_name] == file_size:
elif not ignore_size and keys[key_name] == file_size:
if not quiet:
sys.stdout.write(
'Skipping %s (size matches)\n' %
Expand Down Expand Up @@ -663,7 +669,7 @@ def main():
else:
sys.stdout.write('Skipping %s (not overwriting)\n' %
filename)
elif key.size == file_size:
elif not ignore_size and key.size == file_size:
copy_file = False
if not quiet:
if filename != key_name.split('/')[-1]:
Expand Down Expand Up @@ -766,7 +772,7 @@ def main():
fullpath.split(os.sep)[-1]
)
copy_file = False
elif key.size == os.path.getsize(fullpath):
elif not ignore_size and key.size == os.path.getsize(fullpath):
if not quiet:
if rename:
sys.stdout.write(
Expand Down Expand Up @@ -856,15 +862,21 @@ def main():
fullpath[len(os.path.join(path, '')):]
)
continue
elif key.size == os.path.getsize(fullpath) or \
key.name.endswith('/') or \
key.name.endswith('_$folder$'):
elif not ignore_size and key.size == os.path.getsize(fullpath):
if not quiet:
sys.stdout.write(
'Skipping %s (size matches)\n' %
fullpath[len(os.path.join(path, '')):]
)
continue
elif key.name.endswith('/') or \
key.name.endswith('_$folder$'):
if not quiet:
sys.stdout.write(
'Skipping %s (is directory)\n' %
fullpath[len(os.path.join(path, '')):]
)
continue

if cloud_service == 'gs':
sys.stdout.write('%s\n' %
Expand Down Expand Up @@ -976,7 +988,7 @@ def main():
'Skipping %s (not overwriting)\n' % fullpath
)
copy_file = False
elif key.size == dest_key.size:
elif not ignore_size and key.size == dest_key.size:
if not quiet:
if rename:
sys.stdout.write(
Expand Down Expand Up @@ -1084,7 +1096,7 @@ def main():
fullpath.replace('_$folder$', '/')
)
continue
elif key.size == dest_key.size:
elif not ignore_size and key.size == dest_key.size:
if not quiet:
sys.stdout.write(
'Skipping %s (size matches)\n' %
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os, sys
try:
from distutils.core import setup
except ImportError:
from setuptools import setup
except ImportError:
from distutils.core import setup

install_requires = ['boto>=2.2.1']

Expand Down