Skip to content

Commit fe9a0b3

Browse files
committed
fixup! Encapsulate file mirroring in service class
1 parent 57cc23c commit fe9a0b3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/azul/indexer/mirror_service.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class FilePart(SerializableAttrs):
5252
"""
5353
A part of a mirrored file
5454
"""
55-
#: The part number, starting at 0 for the first part. Note that the S3 API
56-
#: numbers parts starting at 1.
55+
#: The part number, starting at 0 for the first part, unlike S3 API part
56+
#: numbers, which start at 1.
5757
#:
5858
index: int
5959

@@ -64,7 +64,7 @@ class FilePart(SerializableAttrs):
6464
#:
6565
size: int
6666

67-
#: Various quotas related to parts and part sizes
67+
#: Various S3 quotas related to parts and part sizes
6868
#: https://docs.aws.amazon.com/AmazonS3/latest/userguide/qfacts.html
6969
#:
7070
min_size: ClassVar[int] = 5 * 1024 ** 2
@@ -102,14 +102,13 @@ def next(self, file: File) -> Self | None:
102102
last part.
103103
"""
104104
assert file.size is not None, R('File size unknown', file)
105-
stop = self.offset + self.size
106-
if stop == file.size:
105+
next_offset = self.offset + self.size
106+
if next_offset == file.size:
107107
return None
108-
elif 0 < stop < file.size:
109-
return attr.evolve(self,
110-
index=self.index + 1,
111-
offset=stop,
112-
size=min(self.size, file.size - stop))
108+
elif 0 < next_offset < file.size:
109+
next_index = self.index + 1
110+
next_size = min(self.size, file.size - next_offset)
111+
return attr.evolve(self, index=next_index, offset=next_offset, size=next_size)
113112
else:
114113
assert False, R('Part range exceeds file size', self, file)
115114

0 commit comments

Comments
 (0)