Skip to content

Commit e861a36

Browse files
committed
fix: composesource object_size property should not call itself recursively
Signed-off-by: Tamas Kurics <[email protected]>
1 parent 6daf366 commit e861a36

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

minio/commonconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,12 @@ def build_headers(self, object_size: int, etag: str):
466466
@property
467467
def object_size(self) -> Optional[int]:
468468
"""Get object size."""
469-
if self.object_size is None:
469+
if self._object_size is None:
470470
raise MinioException(
471471
"build_headers() must be called prior to "
472472
"this method invocation",
473473
)
474-
return self.object_size
474+
return self._object_size
475475

476476
@property
477477
def headers(self) -> dict[str, str]:

tests/unit/composesource_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
# MinIO Python Library for Amazon S3 Compatible Cloud Storage,
3+
# (C) 2015, 2016 MinIO, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
from unittest import TestCase
17+
18+
from minio.commonconfig import ComposeSource
19+
from minio.error import MinioException
20+
21+
22+
class ComposeSourceTest(TestCase):
23+
def test_object_size(self):
24+
source = ComposeSource(bucket_name="my-bucket",
25+
object_name="my-object")
26+
with self.assertRaises(MinioException) as exc:
27+
_ = source.object_size
28+
29+
msg = "build_headers() must be called prior to this method invocation"
30+
self.assertEqual(msg, str(exc.exception))

0 commit comments

Comments
 (0)