diff --git a/CHANGELOG.md b/CHANGELOG.md index 431e3a9c..a0bbfb55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.9.37] - 2023-01-10 +### Updated +- File download: return last_modified + ## [1.9.36] - 2023-01-09 ### Updated - dependencies diff --git a/README.md b/README.md index aeb1b281..45534aac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OctoBot-Commons [1.9.36](https://github.com/Drakkar-Software/OctoBot-Commons/blob/master/CHANGELOG.md) +# OctoBot-Commons [1.9.37](https://github.com/Drakkar-Software/OctoBot-Commons/blob/master/CHANGELOG.md) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b31f3ab3511744a5a5ca6b9bb48e77bb)](https://app.codacy.com/gh/Drakkar-Software/OctoBot-Commons?utm_source=github.com&utm_medium=referral&utm_content=Drakkar-Software/OctoBot-Commons&utm_campaign=Badge_Grade_Dashboard) [![PyPI](https://img.shields.io/pypi/v/OctoBot-Commons.svg)](https://pypi.python.org/pypi/OctoBot-Commons/) [![Coverage Status](https://coveralls.io/repos/github/Drakkar-Software/OctoBot-Commons/badge.svg?branch=master)](https://coveralls.io/github/Drakkar-Software/OctoBot-Commons?branch=master) diff --git a/octobot_commons/__init__.py b/octobot_commons/__init__.py index e2c2e11c..2334973f 100644 --- a/octobot_commons/__init__.py +++ b/octobot_commons/__init__.py @@ -16,7 +16,7 @@ # License along with this library. PROJECT_NAME = "OctoBot-Commons" -VERSION = "1.9.36" # major.minor.revision +VERSION = "1.9.37" # major.minor.revision MARKET_SEPARATOR = "/" SETTLEMENT_ASSET_SEPARATOR = ":" diff --git a/octobot_commons/aiohttp_util.py b/octobot_commons/aiohttp_util.py index 1eca1dd3..fdf08a83 100644 --- a/octobot_commons/aiohttp_util.py +++ b/octobot_commons/aiohttp_util.py @@ -21,7 +21,7 @@ async def download_stream_file( aiohttp_session, data_chunk_size=5 * 2**20, is_aiofiles_output_file=False, -): +) -> str: """ Download a big file with an aiohttp session :param output_file: the output file @@ -29,13 +29,16 @@ async def download_stream_file( :param aiohttp_session: the aiohttp session :param data_chunk_size: default value is 5*2**20 (5MB) :param is_aiofiles_output_file: When True, output_file.write will be awaited (when it's an aiofiles instance) + :return downloaded file last_modified if given as response header """ + last_modified = None async with aiohttp_session.get(file_url) as resp: if resp.status != 200: raise RuntimeError( f"Failed to download file at url : {file_url} (status: {resp.status})" ) while True: + last_modified = resp.headers.get("Last-Modified", "unknown") chunk = await resp.content.read(data_chunk_size) if not chunk: # resp.content.read returns an empty chunk when completed @@ -44,3 +47,4 @@ async def download_stream_file( await output_file.write(chunk) else: output_file.write(chunk) + return last_modified