Skip to content

Commit 550507a

Browse files
cauriolcauriol
authored andcommitted
fix: clean code
1 parent 587b4b3 commit 550507a

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

stac_fastapi/eodag/extensions/data_download.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def _handle_zarr(
158158
headers["content-type"] = content_type
159159

160160
return StreamingResponse(
161-
content=self._read_file_chunks(open(str(file_full_path), "rb")),
161+
content=self._read_file_chunks_and_delete(open(str(file_full_path), "rb")),
162162
headers=headers,
163163
)
164164
try:
@@ -213,17 +213,6 @@ def _file_to_stream(
213213
},
214214
)
215215

216-
def _read_file_chunks(self, opened_file: BufferedReader, chunk_size: int = 64 * 1024) -> Iterator[bytes]:
217-
"""Yield file chunks without deleting."""
218-
try:
219-
while True:
220-
data = opened_file.read(chunk_size)
221-
if not data:
222-
break
223-
yield data
224-
finally:
225-
opened_file.close()
226-
227216
def _read_file_chunks_and_delete(self, opened_file: BufferedReader, chunk_size: int = 64 * 1024) -> Iterator[bytes]:
228217
"""Yield file chunks and delete file when finished."""
229218
while True:

0 commit comments

Comments
 (0)