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 2 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
26 changes: 26 additions & 0 deletions tests/functional/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,32 @@ def test_upload_snowball_objects(log_entry):
_CLIENT.remove_object(bucket_name, "my-object3")
_CLIENT.remove_bucket(bucket_name)

# run with staging file option
Copy link
Member

Choose a reason for hiding this comment

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

Have def _test_upload_snowball_objects(log_entry, staging_filename): and use the method to have two tests named test_upload_snowball_objects() and test_upload_snowball_objects_staging_file to avoid code duplication.

try:
_CLIENT.make_bucket(bucket_name)
size = 3 * MB
reader1 = LimitedRandomReader(size)
reader2 = LimitedRandomReader(size)
_CLIENT.upload_snowball_objects(
bucket_name,
[
SnowballObject("my-object1", data=io.BytesIO(b"py"), length=2),
SnowballObject(
"my-object2", data=reader1, length=size,
),
SnowballObject(
"my-object3", data=reader2, length=size,
mod_time=datetime.now(),
),
],
staging_filename="staging.tar"
Copy link
Member

Choose a reason for hiding this comment

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

Use random filename here like f"{uuid4()}.tar"

)
_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)

def main():
"""
Expand Down