S3: Close filehandle of versioned keys (#5587)
This commit is contained in:
parent
80ab997010
commit
6f710189ce
@ -1455,12 +1455,10 @@ class S3Backend(BaseBackend, CloudWatchMetricProvider):
|
||||
def reset(self):
|
||||
# For every key and multipart, Moto opens a TemporaryFile to write the value of those keys
|
||||
# Ensure that these TemporaryFile-objects are closed, and leave no filehandles open
|
||||
for bucket in self.buckets.values():
|
||||
for key in bucket.keys.values():
|
||||
if isinstance(key, FakeKey):
|
||||
key.dispose()
|
||||
for mp in bucket.multiparts.values():
|
||||
for mp in FakeMultipart.instances:
|
||||
mp.dispose()
|
||||
for key in FakeKey.instances:
|
||||
key.dispose()
|
||||
super().reset()
|
||||
|
||||
@property
|
||||
|
@ -56,6 +56,11 @@ class TestS3FileHandleClosures(TestCase):
|
||||
def test_overwriting_file(self):
|
||||
self.s3.put_object("my-bucket", "my-key", "b" * 10_000_000)
|
||||
|
||||
@verify_zero_warnings
|
||||
def test_versioned_file(self):
|
||||
self.s3.put_bucket_versioning("my-bucket", "Enabled")
|
||||
self.s3.put_object("my-bucket", "my-key", "b" * 10_000_000)
|
||||
|
||||
@verify_zero_warnings
|
||||
def test_copy_object(self):
|
||||
key = self.s3.get_object("my-bucket", "my-key")
|
||||
|
Loading…
Reference in New Issue
Block a user