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

Fix upload snowball objects with staging file #1286

Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 0 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,8 @@ def upload_snowball_objects(self, bucket_name, object_list, metadata=None,
if not name:
length = fileobj.tell()
fileobj.seek(0)
else:
length = os.stat(name).st_size

if name:
return self.fput_object(bucket_name, object_name, staging_filename,
Expand Down
16 changes: 15 additions & 1 deletion tests/functional/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ def test_remove_bucket(log_entry):
_CLIENT.remove_bucket(bucket_name)


def test_upload_snowball_objects(log_entry):
def _test_upload_snowball_objects(log_entry, staging_filename=None):
"""Test upload_snowball_objects()."""

# Get a unique bucket_name
Expand All @@ -1883,13 +1883,26 @@ def test_upload_snowball_objects(log_entry):
mod_time=datetime.now(),
),
],
staging_filename=staging_filename
)
_test_list_objects_api(bucket_name, 3)
finally:
_CLIENT.remove_object(bucket_name, "my-object1")
_CLIENT.remove_object(bucket_name, "my-object2")
_CLIENT.remove_object(bucket_name, "my-object3")
_CLIENT.remove_bucket(bucket_name)
if staging_filename and os.path.exists(staging_filename):
os.remove(staging_filename)

def test_upload_snowball_objects(log_entry):
"""Test upload_snowball_objects()."""
_test_upload_snowball_objects(log_entry)


def test_upload_snowball_objects_with_staging(log_entry):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add in-line comment # pylint: disable=invalid-name to ignore this pylint error.

"""Test upload_snowball_objects() with staging file."""
staging_filename = f"{uuid4()}.tar"
_test_upload_snowball_objects(log_entry, staging_filename)


def main():
Expand Down Expand Up @@ -1989,6 +2002,7 @@ def main():
test_get_bucket_notification: None,
test_select_object_content: None,
test_upload_snowball_objects: None,
test_upload_snowball_objects_with_staging: None,
}
else:
tests = {
Expand Down