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

Don't upload archive to S3 if zipping fails. #42

Merged
merged 1 commit into from
Jun 7, 2017
Merged
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
2 changes: 1 addition & 1 deletion cucoslib/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def zip_file(file, archive, junk_paths=False):
# Store just the name of a saved file (junk the path), not directory names.
# By default, zip will store the full path (relative to the current directory).
command.extend(['--junk-paths'])
TimedCommand.get_command_output(command)
TimedCommand.get_command_output(command, graceful=False)

@staticmethod
def extract_zip(target, dest, mkdest=False):
Expand Down
9 changes: 7 additions & 2 deletions cucoslib/storages/s3_mavenindex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from cucoslib.errors import TaskError
from cucoslib.process import Archive
from cucoslib.utils import tempdir
from . import AmazonS3
Expand All @@ -13,8 +14,12 @@ def store_index(self, target_dir):
with tempdir() as temp_dir:
central_index_dir = os.path.join(target_dir, self._INDEX_DIRNAME)
archive_path = os.path.join(temp_dir, self._INDEX_ARCHIVE)
Archive.zip_file(central_index_dir, archive_path, junk_paths=True)
self.store_file(archive_path, self._INDEX_ARCHIVE)
try:
Archive.zip_file(central_index_dir, archive_path, junk_paths=True)
except TaskError:
pass
else:
self.store_file(archive_path, self._INDEX_ARCHIVE)

def retrieve_index_if_exists(self, target_dir):
""" Retrieve central-index.zip from S3 and extract into target_dir/central-index"""
Expand Down
9 changes: 7 additions & 2 deletions cucoslib/storages/s3_owaspdepcheck.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from cucoslib.errors import TaskError
from cucoslib.process import Archive
from cucoslib.utils import tempdir
from . import AmazonS3
Expand All @@ -13,8 +14,12 @@ def store_depcheck_db(self, data_dir):
with tempdir() as archive_dir:
archive_path = os.path.join(archive_dir, self._DB_ARCHIVE)
db_file_path = os.path.join(data_dir, self._DB_FILENAME)
Archive.zip_file(db_file_path, archive_path, junk_paths=True)
self.store_file(archive_path, self._DB_ARCHIVE)
try:
Archive.zip_file(db_file_path, archive_path, junk_paths=True)
except TaskError:
pass
else:
self.store_file(archive_path, self._DB_ARCHIVE)

def store_depcheck_db_if_not_exists(self, data_dir):
if not self.object_exists(self._DB_ARCHIVE):
Expand Down