Skip to content

Commit

Permalink
Merge branch 'newsapps-keep_s3_files'
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Jan 16, 2015
2 parents d5b1e4a + 85b306c commit 2c0676a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bakery/management/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
help="Display the output of what would have been uploaded \
removed, but without actually publishing."
),
make_option(
"--no-delete",
action="store_true",
dest="no_delete",
default=False,
help=("Keep files in S3, even if they do not exist in the build "
"directory. The default behavior is to delete files in the "
"bucket that are not in the build directory.")
),
)


Expand Down Expand Up @@ -105,7 +114,7 @@ def handle(self, *args, **options):
self.sync_with_s3()

# Delete anything that's left in our keys dict
if not self.dry_run:
if not self.dry_run and not self.no_delete:
self.deleted_files = len(self.s3_key_dict.keys())
if self.deleted_files:
logger.debug("deleting %s keys" % self.deleted_files)
Expand Down Expand Up @@ -185,6 +194,9 @@ def set_options(self, options):
else:
self.dry_run = False

# set the --keep-files option
self.no_delete = options.get('no_delete')

def get_s3_key_dict(self):
"""
Retrieves and returns a dictionary of keys in our s3 bucket.
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def run(self):
),
MEDIA_URL = '/media/',
BAKERY_VIEWS = ('bakery.tests.MockDetailView',),
# The publish management command needs these to exit, but
# we're mocking boto, so we can put nonesense in here
AWS_ACCESS_KEY_ID = 'MOCK_ACCESS_KEY_ID',
AWS_SECRET_ACCESS_KEY = 'MOCK_SECRET_ACCESS_KEY',
)
from django.core.management import call_command
import django
Expand Down

0 comments on commit 2c0676a

Please sign in to comment.